Why Derive the Association Estimate?
In a quantitative-trait association analysis, a genotype dosage is used to predict a measured phenotype. The fitted slope describes the estimated change in the phenotype associated with one additional dosage copy. Its standard error describes how precisely that slope is estimated under the regression model. Both quantities can be obtained directly from sums of squares and cross-products, making clear what information in the data drives the estimate and its precision.
This tutorial considers ordinary least squares (OLS) with one genotype predictor and an intercept. It focuses on deriving and calculating the slope and its standard error, not on confidence intervals or tests.
For an additive dosage, \(g_i\) is commonly coded 0, 1, or 2 copies of an allele. The slope is then expressed in phenotype units per dosage copy. It describes an association in the specified model; by itself, it does not establish that changing genotype causes a change in phenotype.
Centered Sums of Squares
Write \(\bar{g}\) for the sample mean of the genotype dosages and \(\bar{Y}\) for the sample mean phenotype. The centered genotype sum of squares, phenotype sum of squares, and genotype–phenotype cross-product are
Centering separates the slope calculation from the intercept: the slope depends on how genotype and phenotype vary together around their means, relative to how much genotype varies around its mean. If \(S_{gg}=0\), every individual has the same dosage and there is no information to distinguish a genotype slope from the intercept.
Why the Slope Has This Form
OLS chooses the intercept and slope to minimize the residual sum of squares, the sum of squared differences between observed and fitted phenotypes. For any fixed slope, the minimizing intercept makes the mean residual zero, so it equals \(\bar{Y}-\hat{\beta}_1\bar{g}\). Substituting that intercept into the residuals gives
The resulting residual sum of squares, viewed as a function of the slope \(b\), is
Differentiating with respect to \(b\) gives \(-2S_{gY}+2bS_{gg}\). Setting this derivative to zero yields \(b=S_{gY}/S_{gg}\). When \(S_{gg}>0\), the second derivative \(2S_{gg}\) is positive, so this is the minimizing slope. Substitution into the intercept formula gives the OLS intercept. This derivation also shows why both the cross-product and genotype variation matter: the cross-product sets the direction and size of the estimated slope, while \(S_{gg}\) is its denominator.
Residual Variation and the Standard Error
The fitted residual for individual \(i\) is \(e_i=Y_i-\hat{\beta}_0-\hat{\beta}_1g_i\). The residual sum of squares is \(SSE=\sum e_i^2\). With an intercept and one slope, two parameters have been estimated, leaving \(n-2\) residual degrees of freedom. The residual mean square is \(MSE=SSE/(n-2)\), and the estimated residual standard deviation is \(\sqrt{MSE}\).
To justify the variance result, write \(x_i=g_i-\bar{g}\). The slope formula and the model imply
Conditional on the genotypes, the errors have variance \(\sigma^2\) and are independent. Therefore, the variance of their weighted sum is \(\sigma^2\sum x_i^2\). Since \(\sum x_i^2=S_{gg}\), dividing by \(S_{gg}^2\) gives
Replacing the unknown \(\sigma^2\) with \(MSE\) produces the estimated standard error. This formula relies on the common-variance model; if the residual variance changes with genotype, this model-based standard error need not be appropriate.
Worked Example: Calculating the Slope and Standard Error From Summaries
Suppose a hypothetical sample has 50 individuals. Its dosage distribution is two individuals with dosage 0, 46 with dosage 1, and two with dosage 2. The phenotype data have \(\bar{Y}=12.4\), \(S_{gY}=2.4\), and \(S_{YY}=38.44\). Calculate the slope and its model-based standard error.
Check the genotype variation. The genotype sum is \(46+2(2)=50\), so \(\bar{g}=50/50=1\). The sum of squared dosages is \(46+4(2)=54\). Thus
Because \(S_{gg}>0\), the slope is estimable. The estimated change in phenotype per dosage copy is
The residual sum of squares follows from \(SSE=S_{YY}-S_{gY}^2/S_{gg}\):
With \(n-2=48\) residual degrees of freedom, \(MSE=37/48\). Therefore,
The estimated association is 0.6000 phenotype units per dosage copy, with a model-based standard error of 0.4390 phenotype units per dosage copy. The calculation assumes the stated regression model and error conditions; the summary statistics alone do not verify those assumptions.
Worked Example: Calculating From Individual Observations
In a hypothetical dataset of six individuals, dosage and phenotype are recorded as follows. The phenotype is measured in arbitrary trait units.
| Individual | Dosage \(g_i\) | Phenotype \(Y_i\) |
|---|---|---|
| 1 | 0 | 10 |
| 2 | 0 | 12 |
| 3 | 1 | 13 |
| 4 | 1 | 14 |
| 5 | 2 | 17 |
| 6 | 2 | 18 |
The means are \(\bar{g}=1\) and \(\bar{Y}=14\). The centered genotype deviations are \(-1,-1,0,0,1,1\), so \(S_{gg}=1+1+0+0+1+1=4\). The cross-product is
Thus the slope is \(13/4=3.25\) trait units per dosage copy. The intercept is \(14-(3.25)(1)=10.75\). The fitted values at dosages 0, 1, and 2 are 10.75, 14, and 17.25. Subtracting these from the observed phenotypes gives residuals \(-0.75, 1.25, -1, 0, -0.25,\) and \(0.75\). Hence
There are \(6-2=4\) residual degrees of freedom, giving \(MSE=3.75/4=0.9375\). The standard error is
trait units per dosage copy. For this small hypothetical sample, independence and a common residual variance are model assumptions, not conclusions established by the table. Normality of errors is also assumed for exact finite-sample inference and is difficult to assess with only six observations.
How Genotype Variability Affects Precision
The standard error formula makes the role of genotype variation explicit. If residual variance is held fixed, increasing \(S_{gg}\) decreases \(SE(\hat{\beta}_1)\) in inverse proportion to \(\sqrt{S_{gg}}\). A sample with more spread in genotype dosage provides more information for distinguishing the slope from the intercept. A larger sample often increases \(S_{gg}\), but sample size alone does not determine it: the distribution of dosages also matters.
Worked Example: Comparing Two Levels of Dosage Variation
Consider two hypothetical samples, each with 12 individuals. In both, suppose the estimated residual variance is \(MSE=9\) phenotype-units squared. Sample A has five dosage-0 individuals, six dosage-1 individuals, and one dosage-2 individual. Sample B has four individuals at each dosage.
For Sample A, \(\sum g_i=8\) and \(\sum g_i^2=10\), so
Its slope standard error is
phenotype units per dosage copy. For Sample B, \(\sum g_i=12\) and \(\sum g_i^2=20\), so \(S_{gg,B}=20-12^2/12=8\). Its standard error is
phenotype units per dosage copy. With the same sample size and the same assumed residual variance, the sample with greater dosage variation has the smaller standard error. The comparison holds the residual variance fixed; in actual data, both genotype variation and phenotype residual variation contribute to precision.
Assumptions and Interpretation in Practice
The calculations are simple, but their meaning depends on the model. Before interpreting a slope or its standard error, check that the analysis has an intercept, that genotype dosage varies, and that a linear change in mean phenotype per dosage copy is a reasonable description for the chosen coding. The model-based standard error additionally relies on independent errors with a common variance. Normal errors give the standard finite-sample distributional result; with nonnormal errors, exact small-sample inference does not follow from these formulas alone.
The slope is an estimated mean difference for a one-copy dosage increase under this linear model. It is not the change in every individual's phenotype, nor does it assert a causal effect. The standard error is not the standard deviation of individual phenotypes: it measures the estimated sampling variability of the slope under the model. It is also not determined by genotype variability alone, because larger residual variation increases the standard error through \(MSE\).
Common Mistakes
- Reversing numerator and denominator. The slope is \(S_{gY}/S_{gg}\), not \(S_{gg}/S_{gY}\). The cross-product measures joint variation; the genotype sum of squares scales it by predictor variation.
- Using phenotype spread in place of residual spread. The standard error uses \(MSE=SSE/(n-2)\), not \(S_{YY}/(n-1)\). The residual variation is what remains after fitting the intercept and slope.
- Using the wrong degrees of freedom. One intercept and one slope are fitted, so the residual degrees of freedom are \(n-2\), not \(n-1\).
- Claiming that more genotype variation always guarantees a precise estimate. It lowers the standard error only with residual variation held fixed. A large residual variance can still make the slope imprecise.
- Trying to estimate a slope when all dosages are identical. If \(S_{gg}=0\), the slope formula divides by zero. The data contain no genotype contrast from which to estimate a per-copy association.
Check Your Understanding
Use the formulas and assumptions in this tutorial to answer the following questions.
- In a one-predictor regression with an intercept, what do \(S_{gY}\) and \(S_{gg}\) each contribute to the slope estimate?
- If all individuals have the same genotype dosage, what is \(S_{gg}\), and why can the slope not be estimated?
- A dataset has \(n=20\), \(S_{gg}=10\), and \(SSE=36\). Calculate \(MSE\) and the model-based standard error of the slope.
- Holding residual mean square fixed, what happens to the slope standard error if \(S_{gg}\) is multiplied by four? Explain using its formula.
- Why is \(S_{YY}\) not substituted for \(SSE\) in the standard error formula?