From Dosage to a Regression Estimate
In an additive quantitative-trait analysis, the SNP dosage \(G_i\) records the number of effect alleles for individual \(i\), usually as 0, 1, or 2; an imputed dosage may take intermediate values. The regression coefficient is estimated from the way the trait values vary with dosage. This tutorial derives that estimate and its standard error for a model with an intercept and one dosage predictor, without additional covariates.
The dosage slope is not calculated by comparing only the average trait values in three genotype groups. Least squares uses all observed dosage-trait pairs and chooses the line that minimizes the sum of squared vertical residuals. The resulting standard error quantifies sampling uncertainty under specified error assumptions; those assumptions are also what make the conventional t-test appropriate.
The slope \(\beta_1\) is the change in the model’s mean trait value for a one-unit increase in dosage, with units of trait per dosage copy. The intercept \(\beta_0\) is the model’s mean at dosage zero. The error \(\varepsilon_i\) is the difference between the observed trait and its conditional mean. Least squares estimates the intercept and slope by minimizing the residual sum of squares.
Deriving the Least-Squares Estimates
Write \(\bar{G}\) and \(\bar{Y}\) for the sample means of dosage and trait. Define the centered sums of squares and cross-products \(S_{GG}=\sum_{i=1}^n(G_i-\bar{G})^2\) and \(S_{GY}=\sum_{i=1}^n(G_i-\bar{G})(Y_i-\bar{Y})\). The least-squares objective for proposed coefficients \(b_0,b_1\) is \(Q(b_0,b_1)=\sum_{i=1}^n(Y_i-b_0-b_1G_i)^2\).
These formulas follow by minimizing \(Q\). Differentiating with respect to \(b_0\) and setting the derivative to zero gives \(\sum_i(Y_i-b_0-b_1G_i)=0\), hence \(b_0=\bar{Y}-b_1\bar{G}\). Substituting that expression into the objective leaves a function of the slope alone:
Differentiating this expression and setting the derivative to zero gives \(-2S_{GY}+2b_1S_{GG}=0\). Because \(S_{GG}>0\), the unique minimizing slope is \(S_{GY}/S_{GG}\), and substituting it into the intercept expression gives the stated estimate. This also shows why a monomorphic SNP, with the same dosage for everyone, has no estimable slope in this model: its \(S_{GG}\) is zero.
Worked Example: Calculating the Dosage Slope
Consider hypothetical data for five individuals. The observed dosages are \(0,1,1,2,2\), and the corresponding trait values are \(10,12,13,13,16\) trait units. The dosages vary, so \(S_{GG}>0\) and the slope is estimable.
The means are \(\bar{G}=1.2\) and \(\bar{Y}=12.8\). The centered sums are \(S_{GY}=3.36+0.16-0.04+0.16+2.56=6.20\) and \(S_{GG}=1.44+0.04+0.04+0.64+0.64=2.80\). Therefore,
The fitted line is \(\widehat{Y}_i=10.143+2.214G_i\). For example, its fitted value at dosage 2 is \(10.143+2(2.214)=14.571\) trait units. These calculations estimate a linear trend across the observed dosages; they do not by themselves establish that the model assumptions hold.
Residual Variance and the Standard Error
For each individual, the fitted value is \(\widehat{Y}_i=\widehat{\beta}_0+\widehat{\beta}_1G_i\), and the residual is \(e_i=Y_i-\widehat{Y}_i\). The residual sum of squares is \(SSE=\sum_i e_i^2\). With an intercept and one estimated slope, the residual variance estimate divides \(SSE\) by \(n-2\), the residual degrees of freedom:
Here \(s_e^2\) estimates the common error variance \(\sigma^2\). The standard error is an estimate of the standard deviation of the slope estimate across repeated samples under the model. A larger residual variance increases the standard error; greater spread in the observed dosages, measured by \(S_{GG}\), decreases it.
The reason for this formula can be seen by treating the observed dosages as fixed. Substituting the model into the slope formula and using \(\sum_i(G_i-\bar{G})=0\) gives \(\widehat{\beta}_1-\beta_1=\sum_i(G_i-\bar{G})\varepsilon_i/S_{GG}\). Under independent errors with variance \(\sigma^2\), the variance of this weighted sum is \(\sigma^2\sum_i(G_i-\bar{G})^2/S_{GG}^2=\sigma^2/S_{GG}\). Replacing the unknown \(\sigma^2\) with \(s_e^2\) gives the estimated standard error above. Under the normal-error assumption, the standardized estimation error divided by the estimated residual standard deviation has a \(t\) distribution with \(n-2\) degrees of freedom. The two degrees of freedom are used to estimate the intercept and slope.
Worked Example: Standard Error From the Fitted Residuals
Continue with the five hypothetical observations above. Their fitted values are \(10.143,12.357,12.357,14.571,14.571\). Subtracting these from the observed trait values gives residuals \(-0.143,-0.357,0.643,-1.571,1.429\) trait units. Squaring and summing gives \(SSE=5.071\) trait-units squared (rounding the displayed residuals only at the end).
There are \(n-2=3\) residual degrees of freedom, so \(s_e^2=5.071/3=1.690\) trait-units squared. Using \(S_{GG}=2.80\),
This is an estimate of the repeated-sampling standard deviation of the slope under the model. It is not the standard deviation of the observed trait values, nor is it a measure of how much the fitted slope itself changes within this one sample.
The Usual t-Test and Confidence Interval
To test whether the dosage coefficient is zero, use \(H_0:\beta_1=0\) against a specified alternative, commonly \(H_a:\beta_1\ne0\). Under the model assumptions, the test statistic has a \(t\) distribution with \(n-2\) degrees of freedom when \(H_0\) is true. The two-sided p-value is the probability, under that null model, of a t statistic at least as far from zero as the observed statistic.
A \(100(1-\alpha)\%\) confidence interval for the slope is \(\widehat{\beta}_1\pm t_{1-\alpha/2,n-2}SE(\widehat{\beta}_1)\), where \(t_{1-\alpha/2,n-2}\) is the corresponding quantile of the \(t\) distribution. Its coverage interpretation concerns repeated samples under the model: the procedure produces intervals that contain the fixed coefficient at the stated rate when the assumptions hold.
Worked Example: Testing a Slope From Summary Statistics
Suppose a hypothetical sample of \(n=100\) individuals has \(S_{GG}=80\), \(S_{GY}=28\), and fitted-model \(SSE=392\). These are the centered dosage sum of squares, dosage-trait cross-product, and residual sum of squares for the stated unadjusted model; the dosage values are not all equal. The coefficient estimate is \(28/80=0.350\) trait units per dosage copy. The residual variance estimate is \(392/(100-2)=4.000\) trait-units squared, so
For \(H_0:\beta_1=0\) against \(H_a:\beta_1\ne0\), the statistic is \(t=0.350/0.2236=1.565\), with \(df=98\). The two-sided p-value is approximately \(0.121\). At the \(0.05\) significance level, this test does not reject the zero-slope null hypothesis; that result is not proof that the true slope is zero.
Using \(t_{0.975,98}\approx1.984\), a 95% confidence interval is \(0.350\pm1.984(0.2236)=0.350\pm0.444\), or approximately \((-0.094,0.794)\) trait units per dosage copy. The interval includes zero, consistent with the two-sided test at level \(0.05\).
Assumptions, Diagnostics, and Alternatives
The exact t reference distribution requires the stated normal, independent, equal-variance errors and a correctly specified linear conditional mean. Normality is not required for the least-squares formulas themselves, but it is required for the exact finite-sample t result. With sufficiently large samples, t-based inference may be approximately valid under weaker distributional conditions, but that is not a guarantee when errors are strongly dependent, highly influential, or severely heteroskedastic.
Useful checks include plotting residuals against fitted values and dosage, looking for changing residual spread or a systematic curve, and identifying observations with unusually large residuals or leverage. A residual-versus-fitted plot with a funnel shape suggests unequal variance; curvature suggests that a straight-line mean may be inadequate. These checks can reveal warning signs but cannot establish independence or prove that errors are normal. In genomic data, related individuals or other sources of sample dependence can make the independent-error standard error inappropriate.
When the assumptions fail, the slope formula can still describe the least-squares line, but the conventional standard error and t calibration may be unreliable. Heteroskedasticity-robust standard errors address unequal variances under suitable independence conditions; resampling or permutation approaches require their own validity conditions. These are alternative inferential procedures, not changes to the least-squares slope itself. A dosage with very little variation also yields a small \(S_{GG}\), and therefore potentially a large standard error; no statistical method can recover information absent from the observed genotypes.
In the simple model with an intercept, testing the slope is equivalent to testing zero linear correlation between dosage and trait: both tests are based on the same centered cross-product and have the same t statistic. This equivalence is specific to the one-predictor setting. It does not mean that correlation is a substitute for a regression model in settings where additional predictors or a different conditional mean are needed.
Common Mistake
A common error is to divide \(SSE\) by \(n\), or by \(n-1\), when estimating residual variance for this regression. The correction is to use \(n-2\): two parameters, the intercept and slope, have been estimated from the same observations. A second error is to use the resulting t-test automatically whenever a slope can be calculated. The slope is algebraically available whenever \(S_{GG}>0\), but its usual standard error and t-test rely on the error assumptions; calculation alone does not validate inference.
Check Your Understanding
Answer each question, then compare with the solutions below.
- If \(S_{GY}=18\) and \(S_{GG}=60\), what is the least-squares dosage slope, including its units if the trait is measured in milligrams?
- A fitted model has \(n=40\) observations and \(SSE=76\). What residual variance estimate and residual degrees of freedom are used?
- If all individuals have the same dosage, can the model estimate a dosage slope? Explain using \(S_{GG}\).
- What assumptions give the usual exact t distribution for the slope test, and what is its degrees of freedom?
- A residual plot shows a clear increase in spread as fitted trait values increase. Why might the conventional standard error be questionable?
Solutions. 1. The slope is \(18/60=0.300\) milligrams per dosage copy. 2. The residual degrees of freedom are \(40-2=38\), and the residual variance estimate is \(76/38=2.00\) milligrams squared. 3. No. If all dosages are equal, every \(G_i-\bar{G}=0\), so \(S_{GG}=0\) and the slope formula has a zero denominator. 4. Conditional on the observed dosages, the errors must be independent and normally distributed with mean zero and common variance, and the linear mean model must be appropriate; the test has \(n-2\) degrees of freedom. 5. Increasing spread suggests heteroskedasticity, contrary to the common-variance assumption used by the conventional standard error, so its t calibration may not be reliable.