Tutorials › Statistical Genetics › Residualization and the Frisch–Waugh–Lovell Result

Conditional and Joint Association · Tutorial 600 of 989

Residualization and the Frisch–Waugh–Lovell Result

Learn why a variant’s coefficient in a conditional regression is exactly the slope relating phenotype and genotype after both have been residualized against the same covariates and other variants.

Advanced 11 min read

What You'll Learn

  • Define the nuisance design matrix and residual-maker for a locus regression
  • Derive the Frisch–Waugh–Lovell coefficient identity
  • Calculate a conditional variant coefficient from residualized data
  • Distinguish a residual-regression slope from a residual correlation
  • Use the full-model residual degrees of freedom for the conventional standard error
  • Recognize when rank, sample, or model differences invalidate the comparison

Why Residualize Both Sides?

A variant’s conditional regression coefficient describes its association with phenotype while holding specified covariates and other included variants fixed. The Frisch–Waugh–Lovell result gives an equivalent way to calculate that coefficient: first remove from the phenotype and target genotype everything linearly explained by the same nuisance variables, then regress one set of residuals on the other. This is useful for understanding what “conditional” means algebraically, and for seeing precisely which part of a genotype contributes to its coefficient.

The operation must be performed on both the phenotype and the target genotype. Residualizing only the phenotype, or only the genotype, generally does not recover the conditional coefficient. The residualization must also use the same observations and the same nuisance variables on both sides.

Model and Residualization

Suppose there are \(n\) observations. Let \(y\) be the \(n\)-vector of phenotype values, and let \(g_j\) be the \(n\)-vector of dosages for the target variant \(j\). Write \(C\) for the nuisance design matrix: its columns contain an intercept, any included covariates, and the genotype columns for the other variants in the conditional model. The model is

$$ y=C\gamma+g_j\beta_j+\varepsilon. $$

Here \(\beta_j\) is the coefficient of interest, and \(\gamma\) contains the nuisance coefficients. Assume the observations and columns are arranged consistently throughout, \(C\) has full column rank, and \(g_j\) is not an exact linear combination of the columns of \(C\). These conditions ensure that the model coefficients are identifiable. The algebraic result below does not require normally distributed errors; assumptions for conventional standard errors and tests are discussed separately.

Definition: The projection matrix onto the columns of \(C\) is \(P_C=C(C^\mathsf{T}C)^{-1}C^\mathsf{T}\). The residual-maker is \(M_C=I-P_C\). For any vector \(v\), \(M_Cv\) is the residual vector from regressing \(v\) on the columns of \(C\). It is orthogonal to every column of \(C\).

The residual-maker is symmetric and idempotent: \(M_C^\mathsf{T}=M_C\) and \(M_C^2=M_C\). Define the residualized phenotype and genotype as \(y^*=M_Cy\) and \(g_j^*=M_Cg_j\). They contain the parts of \(y\) and \(g_j\) that cannot be linearly explained by \(C\). In particular, \(g_j^*\) is the variation in the target genotype that remains after accounting for the other included variables.

The Frisch–Waugh–Lovell Result

Theorem: In the ordinary least-squares model \(y=C\gamma+g_j\beta_j+\varepsilon\), under the rank conditions above, the coefficient on \(g_j\) is
$$ \hat{\beta}_j = \frac{g_j^\mathsf{T}M_Cy}{g_j^\mathsf{T}M_Cg_j} = \frac{(g_j^*)^\mathsf{T}y^*}{(g_j^*)^\mathsf{T}g_j^*}. $$

Thus \(\hat{\beta}_j\) is the slope from an ordinary least-squares regression of residualized phenotype on residualized genotype through the origin. When \(C\) includes an intercept, both residual vectors have mean zero, so the through-origin formulation is natural. This coefficient is a regression slope, not a correlation: it retains the units of phenotype per genotype-dosage unit.

A short derivation makes clear why the same \(C\) must be used for both variables. For a fixed candidate value \(\beta\), choose \(\gamma\) to minimize the residual sum of squares. The least-squares fit of \(y-g_j\beta\) on \(C\) leaves residual vector \(M_C(y-g_j\beta)\). Therefore the full model’s residual sum of squares, after minimizing over \(\gamma\), is

$$ \begin{aligned} S(\beta) &=[M_C(y-g_j\beta)]^\mathsf{T}[M_C(y-g_j\beta)]\\ &=(y-g_j\beta)^\mathsf{T}M_C(y-g_j\beta)\\ &=y^\mathsf{T}M_Cy-2\beta g_j^\mathsf{T}M_Cy +\beta^2g_j^\mathsf{T}M_Cg_j. \end{aligned} $$

The second equality uses symmetry and idempotence of \(M_C\). Differentiating this quadratic with respect to \(\beta\) and setting the derivative to zero gives

$$ \frac{dS(\beta)}{d\beta} =-2g_j^\mathsf{T}M_Cy+2\beta g_j^\mathsf{T}M_Cg_j=0, \qquad \hat{\beta}_j=\frac{g_j^\mathsf{T}M_Cy}{g_j^\mathsf{T}M_Cg_j}. $$

Finally, symmetry and idempotence also give \(g_j^\mathsf{T}M_Cy=(M_Cg_j)^\mathsf{T}(M_Cy)\) and \(g_j^\mathsf{T}M_Cg_j=(M_Cg_j)^\mathsf{T}(M_Cg_j)\). Substituting \(g_j^*\) and \(y^*\) yields the residual-regression formula. The denominator is positive precisely when \(g_j\) has variation remaining after projection on \(C\).

Worked Example: Recovering a Conditional Coefficient

Consider a hypothetical sample of five individuals. Let \(z\) be a measured covariate and \(h\) the dosage of another included variant. The target variant’s dosage is \(g_j\), and the phenotype is \(y\). The nuisance matrix \(C\) contains an intercept, \(z\), and \(h\).

$$ z=(-2,-1,0,1,2)^\mathsf{T},\quad h=(1,-2,2,-2,1)^\mathsf{T},\quad g_j=(0,1,2,1,0)^\mathsf{T},\quad y=(8.38,7.68,11.48,10.48,11.98)^\mathsf{T}. $$

To residualize \(g_j\), project it onto the intercept and the two nuisance columns. Its mean is \(4/5=0.8\), and its inner products with \(z\) and \(h\) are both zero: \(z^\mathsf{T}g_j=-1+1=0\) and \(h^\mathsf{T}g_j=-2+4-2=0\). These columns are mutually orthogonal, so the projection of \(g_j\) onto \(C\) is just its mean times the intercept. Hence

$$ g_j^*=g_j-0.8\mathbf{1} =(-0.8,0.2,1.2,0.2,-0.8)^\mathsf{T}. $$

For the phenotype, direct projection on \(C\) gives fitted values \((8.5,7.5,11,10,12.5)^\mathsf{T}\), so \(y^*=(-0.12,0.18,0.48,0.48,-0.52)^\mathsf{T}\). The residual-regression numerator and denominator are

$$ (g_j^*)^\mathsf{T}y^* =0.096+0.036+0.576+0.096+0.416=1.22, \qquad (g_j^*)^\mathsf{T}g_j^* =0.64+0.04+1.44+0.04+0.64=2.8. $$

Therefore \(\hat{\beta}_j=1.22/2.8=0.4357\). In this hypothetical model, the fitted conditional association is an increase of about \(0.436\) phenotype units per additional dosage unit, after linear adjustment for \(z\) and \(h\). The calculation is exactly the target coefficient from the full regression on the same five individuals.

What the Residual Slope Does—and Does Not—Say

The residual slope measures how phenotype residuals change with genotype residuals. It does not measure the association between the original phenotype and the original genotype, and it does not by itself establish a causal effect. In a genetic association model, its interpretation is conditional on the covariates and other included variants, the chosen phenotype scale, and the linear model specification.

A residual correlation is a different quantity. If \(r\) denotes the correlation between \(y^*\) and \(g_j^*\), then the slope can be written as \(r\,s_{y^*}/s_{g_j^*}\), where \(s_{y^*}\) and \(s_{g_j^*}\) are the sample standard deviations of the residuals. Correlation is unitless; the regression slope has phenotype units per dosage unit. A high residual correlation need not imply a large slope if the residual genotype variation is small.

Worked Example: Slope Is Not Correlation

Suppose a hypothetical nuisance regression has already produced the following four residuals for phenotype and target genotype: \(y^*=(-3,0,2,1)^\mathsf{T}\) and \(g_j^*=(-2,-1,1,2)^\mathsf{T}\). Their means are both zero, as expected if the nuisance set included an intercept. The conditional coefficient is

$$ \hat{\beta}_j =\frac{(-2)(-3)+(-1)(0)+(1)(2)+(2)(1)} {(-2)^2+(-1)^2+1^2+2^2} =\frac{10}{10}=1. $$

The residual correlation, in contrast, is \(10/\sqrt{10\cdot14}=0.8452\), since the residual sums of squares are \(10\) for genotype and \(14\) for phenotype. The slope is \(1\) phenotype unit per dosage unit, while the correlation is a unitless measure of linear alignment. They are related, but they are not interchangeable.

Standard Errors and the Full Model

The coefficient identity is an algebraic property of least squares. It does not, by itself, determine a standard error or a p-value. For the conventional ordinary least-squares standard error, assume errors are independent with mean zero and common variance \(\sigma^2\). If errors are also normally distributed, the usual t reference distribution is exact under the null. Let \(q\) be the number of linearly independent columns of \(C\). The full model has \(q+1\) fitted coefficients, and its residual degrees of freedom are \(n-q-1\). With residual sum of squares \(SSE\) from the full model, the conventional estimated variance is \(\hat{\sigma}^2=SSE/(n-q-1)\), and

$$ SE(\hat{\beta}_j)= \sqrt{\frac{\hat{\sigma}^2}{(g_j^*)^\mathsf{T}g_j^*}}. $$

The residual-only regression reproduces the coefficient and the full model’s residuals, so it reproduces \(SSE\) as well. But its degrees of freedom must still account for the nuisance coefficients already estimated. Treating it as a standalone regression with only one predictor and using \(n-2\) degrees of freedom would generally give the wrong variance estimate. If the error structure is not independent and homoskedastic, the conventional formula may not apply; an appropriate variance estimator must reflect that structure.

Worked Example: Using the Correct Residual Degrees of Freedom

Suppose a hypothetical analysis has \(n=6\) observations, a nuisance matrix \(C\) of rank \(q=3\), and residualized vectors \(g_j^*=(-1,0,1,-1,0,1)^\mathsf{T}\) and \(y^*=(-2,0,2,0,-1,1)^\mathsf{T}\). These are assumed to come from residualizing both variables against the same three-dimensional nuisance space. The coefficient calculation is

$$ (g_j^*)^\mathsf{T}g_j^*=6,\qquad (g_j^*)^\mathsf{T}y^*=5,\qquad \hat{\beta}_j=\frac{5}{6}=0.8333. $$

The residual sum of squares after fitting this coefficient is \(SSE=(y^*)^\mathsf{T}y^*-\{(g_j^*)^\mathsf{T}y^*\}^2/(g_j^*)^\mathsf{T}g_j^*=10-25/6=35/6\). The full model has \(q+1=4\) coefficients, so \(df=6-4=2\), and \(\hat{\sigma}^2=(35/6)/2=35/12\). Thus

$$ SE(\hat{\beta}_j) =\sqrt{\frac{35/12}{6}} =\sqrt{\frac{35}{72}} =0.6972. $$

This standard error uses the degrees of freedom from the full model. Using only the residual regression’s sample size and predictor count would fail to account for the three nuisance coefficients. The small residual degrees of freedom also make clear that this hypothetical estimate is imprecise; the example illustrates the calculation, not evidence from an actual study.

Common Mistakes and Practical Checks

  • Residualizing only one variable. Regressing \(y^*\) on the raw genotype, or the raw phenotype on \(g_j^*\), does not implement the theorem. Residualize both against the same \(C\).
  • Changing the nuisance set. If the target genotype is residualized against one set of covariates but the phenotype against another, the displayed coefficient identity no longer follows.
  • Using different observations. Missingness can change projections and coefficients. The full regression and both residualizations must use the same rows.
  • Confusing slope with correlation. The slope has phenotype-per-dosage units; the correlation is unitless. Report and interpret the quantity actually calculated.
  • Ignoring rank deficiency. If \(g_j\) is fully explained by \(C\), then \(g_j^*=0\), the denominator is zero, and its separate conditional coefficient cannot be identified from these data.
  • Reading conditional association as causation. The theorem is a statement about equivalent least-squares calculations. It does not establish that changing genotype would cause the fitted phenotype change.
Key takeaway: In a full-rank ordinary least-squares locus model, the target variant’s conditional coefficient equals the through-origin slope of residualized phenotype on residualized genotype, when both are residualized against the same nuisance design. The coefficient is invariant to this computational reformulation; valid inference still uses the full model’s error and degrees-of-freedom assumptions.

Check Your Understanding

Try these questions without looking back.

  1. In a conditional locus regression, what belongs in the nuisance matrix \(C\) when estimating the coefficient of one target variant?
  2. Why must the phenotype and target genotype be residualized against the same nuisance matrix?
  3. State the Frisch–Waugh–Lovell formula for \(\hat{\beta}_j\) using \(y^*\) and \(g_j^*\).
  4. Explain why the residual-regression slope and residual correlation have different units and interpretations.
  5. If the nuisance matrix has rank \(q\), what residual degrees of freedom are used for the conventional standard error in the full model?
Clinical Biostats