Tutorials › Statistical Genetics › Deriving OLS Association Estimates and Standard Errors

Single-Variant Association Tests · Tutorial 305 of 989

Deriving OLS Association Estimates and Standard Errors

See how the genotype–phenotype cross-product gives the per-copy slope, and how residual variation and genotype spread determine its standard error.

Intermediate 10 min read

What You'll Learn

  • Calculate the centered genotype sum of squares and genotype–phenotype cross-product.
  • Derive the single-predictor OLS slope and intercept from the regression model.
  • Obtain residual variation and the slope’s estimated standard error from sums of squares.
  • Explain why greater genotype variability improves precision when other factors are held fixed.
  • Check model assumptions and recognize when a slope cannot be estimated.

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.

Model: For \(n\) individuals, let \(g_i\) be individual \(i\)'s genotype dosage and \(Y_i\) the quantitative phenotype. The single-predictor linear model is \(Y_i=\beta_0+\beta_1g_i+\varepsilon_i\). Here, \(\beta_0\) is the intercept, \(\beta_1\) is the change in the conditional mean phenotype per dosage copy, and \(\varepsilon_i\) is the error. For the usual model-based standard error, assume the errors are independent, have mean zero conditional on the genotypes, have a common variance \(\sigma^2\), and are normally distributed for exact finite-sample inference. The genotype dosages must vary across individuals.

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

$$ S_{gg}=\sum_{i=1}^{n}(g_i-\bar{g})^2,\qquad S_{YY}=\sum_{i=1}^{n}(Y_i-\bar{Y})^2,\qquad S_{gY}=\sum_{i=1}^{n}(g_i-\bar{g})(Y_i-\bar{Y}). $$

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.

Definition: In a single-predictor OLS regression with an intercept, the estimated genotype slope is \(\hat{\beta}_1=S_{gY}/S_{gg}\), provided \(S_{gg}>0\). The fitted intercept is \(\hat{\beta}_0=\bar{Y}-\hat{\beta}_1\bar{g}\).

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

$$ Y_i-\hat{\beta}_0-\hat{\beta}_1g_i =(Y_i-\bar{Y})-\hat{\beta}_1(g_i-\bar{g}). $$

The resulting residual sum of squares, viewed as a function of the slope \(b\), is

$$ \begin{aligned} RSS(b) &=\sum_{i=1}^{n}\left[(Y_i-\bar{Y})-b(g_i-\bar{g})\right]^2\\ &=S_{YY}-2bS_{gY}+b^2S_{gg}. \end{aligned} $$

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}\).

Result: Under the stated linear-model assumptions, conditional on the observed genotypes, \(\hat{\beta}_1\) has variance \(\sigma^2/S_{gg}\). Estimating \(\sigma^2\) by \(MSE\) gives the model-based estimated standard error \(SE(\hat{\beta}_1)=\sqrt{MSE/S_{gg}}\). The standard error is in phenotype units per dosage copy.

To justify the variance result, write \(x_i=g_i-\bar{g}\). The slope formula and the model imply

$$ \hat{\beta}_1-\beta_1 =\frac{\sum_{i=1}^{n}x_i\varepsilon_i}{S_{gg}}. $$

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

$$ \operatorname{Var}(\hat{\beta}_1\mid g_1,\ldots,g_n) =\frac{\sigma^2S_{gg}}{S_{gg}^2} =\frac{\sigma^2}{S_{gg}}. $$

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

$$ S_{gg}=\sum g_i^2-\frac{(\sum g_i)^2}{n} =54-\frac{50^2}{50}=4. $$

Because \(S_{gg}>0\), the slope is estimable. The estimated change in phenotype per dosage copy is

$$ \hat{\beta}_1=\frac{S_{gY}}{S_{gg}} =\frac{2.4}{4}=0.6000. $$

The residual sum of squares follows from \(SSE=S_{YY}-S_{gY}^2/S_{gg}\):

$$ SSE=38.44-\frac{2.4^2}{4} =38.44-1.44=37. $$

With \(n-2=48\) residual degrees of freedom, \(MSE=37/48\). Therefore,

$$ SE(\hat{\beta}_1) =\sqrt{\frac{MSE}{S_{gg}}} =\sqrt{\frac{37/48}{4}} =\sqrt{\frac{37}{192}} \approx 0.4390. $$

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.

IndividualDosage \(g_i\)Phenotype \(Y_i\)
1010
2012
3113
4114
5217
6218

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

$$ S_{gY} =(-1)(-4)+(-1)(-2)+(0)(-1)+(0)(0)+(1)(3)+(1)(4) =13. $$

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

$$ SSE=(-0.75)^2+(1.25)^2+(-1)^2+0^2+(-0.25)^2+(0.75)^2 =3.75. $$

There are \(6-2=4\) residual degrees of freedom, giving \(MSE=3.75/4=0.9375\). The standard error is

$$ SE(\hat{\beta}_1) =\sqrt{\frac{0.9375}{4}} =\sqrt{0.234375} \approx 0.4841 $$

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

$$ S_{gg,A}=10-\frac{8^2}{12} =\frac{14}{3}\approx4.667. $$

Its slope standard error is

$$ SE_A=\sqrt{\frac{9}{14/3}} =\sqrt{\frac{27}{14}} \approx1.388 $$

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

$$ SE_B=\sqrt{\frac{9}{8}}\approx1.061 $$

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.
Key takeaway: In single-predictor OLS, the per-copy slope is the centered genotype–phenotype cross-product divided by the centered genotype sum of squares. Its model-based standard error is the square root of residual mean square divided by that genotype sum of squares.

Check Your Understanding

Use the formulas and assumptions in this tutorial to answer the following questions.

  1. In a one-predictor regression with an intercept, what do \(S_{gY}\) and \(S_{gg}\) each contribute to the slope estimate?
  2. If all individuals have the same genotype dosage, what is \(S_{gg}\), and why can the slope not be estimated?
  3. A dataset has \(n=20\), \(S_{gg}=10\), and \(SSE=36\). Calculate \(MSE\) and the model-based standard error of the slope.
  4. Holding residual mean square fixed, what happens to the slope standard error if \(S_{gg}\) is multiplied by four? Explain using its formula.
  5. Why is \(S_{YY}\) not substituted for \(SSE\) in the standard error formula?
Clinical Biostats