Tutorials › Causal Inference › Partialling Out Covariates Before IV

Linear IV Estimation · Tutorial 523 of 972

Partialling Out Covariates Before IV

Learn the finite-sample Frisch–Waugh–Lovell result for 2SLS and how to apply it without changing the coefficient on treatment.

Intermediate 12 min read

What You'll Learn

  • Define residualized outcomes, treatments, and excluded instruments using projection on included covariates.
  • Derive the Frisch–Waugh–Lovell equivalence for the treatment coefficient in 2SLS.
  • Calculate a just-identified 2SLS coefficient after removing group covariates.
  • Apply residualized 2SLS with multiple excluded instruments jointly.
  • Check the equivalence using a continuous covariate and explicitly calculated residuals.
  • Identify why residualizing only some variables can produce the wrong estimate.

Why Partial Out Covariates?

In a covariate-adjusted instrumental variables regression, the included exogenous covariates appear both as regressors and as their own instruments. Their role is distinct from that of the excluded instruments: the excluded instruments provide the variation used to identify the treatment coefficient, while the covariates are adjusted for in both stages. The Frisch–Waugh–Lovell result gives a useful way to separate these roles algebraically: remove the linear contribution of the covariates from the outcome, treatment, and excluded instruments, then estimate the IV coefficient using the resulting residuals.

This is an exact finite-sample equivalence for the usual 2SLS coefficient, not an approximation and not a new identification assumption. It can simplify calculations and help clarify which variation contributes to the adjusted coefficient. It does not make an invalid instrument valid, and by itself it does not establish a causal interpretation.

Definition: Let \(y\) be the outcome vector, \(d\) the treatment vector, \(X\) the matrix of included exogenous covariates (including an intercept, if the regression has one), and \(Z\) the matrix of excluded instruments. Assume \(X\) has full column rank. Define \(P_X=X(X'X)^{-1}X'\) and \(M_X=I-P_X\). The residualized variables are \(\tilde y=M_Xy\), \(\tilde d=M_Xd\), and \(\tilde Z=M_XZ\). Thus each residualized variable is what remains after its linear projection on the columns of \(X\) has been removed.

The IV specification is \(y=d\beta+X\gamma+u\), where \(\beta\) is the treatment coefficient and \(\gamma\) collects the coefficients on the included covariates. The instrument matrix for this specification is \([X,Z]\). In 2SLS, the first stage projects the treatment on both the included covariates and the excluded instruments; the second stage regresses the outcome on the fitted treatment and the included covariates. The result below concerns the coefficient on \(d\), not a claim that covariates can be omitted when reporting the original model.

The Partialling-Out Result

The notation \(P_{\tilde Z}\) will mean the projection matrix onto the columns of the residualized excluded-instrument matrix \(\tilde Z\). If those columns are linearly independent, \(P_{\tilde Z}=\tilde Z(\tilde Z'\tilde Z)^{-1}\tilde Z'\). If the instruments contain redundant columns, the same projection is defined onto their column space, using a generalized inverse or a nonredundant basis. For clarity, the formulas below use the full-rank case.

Theorem: Suppose the 2SLS specification includes \(X\) as regressors and as instruments, and uses \(Z\) as excluded instruments. If the required projections are defined and the treatment is identified in the sample, the 2SLS coefficient on \(d\) is $$ \hat\beta_{\mathrm{2SLS}} = \frac{\tilde d'P_{\tilde Z}\tilde y} {\tilde d'P_{\tilde Z}\tilde d}. $$ Equivalently, residualize \(y\), \(d\), and every excluded instrument on the same \(X\), then use ordinary 2SLS with \(\tilde Z\) as instruments for \(\tilde d\). The denominator must be nonzero; in this scalar-treatment case it is positive when the instruments project onto a nonzero component of the residualized treatment.

This expression works with one or several excluded instruments. With one instrument, the projection has rank one and the expression reduces to the ratio of the residualized instrument’s sample association with \(\tilde y\) to its sample association with \(\tilde d\). With multiple instruments, the projection uses their joint column space. It is generally not correct to calculate a separate just-identified IV ratio for each instrument and then treat those ratios as the 2SLS coefficient.

Why the Equivalence Holds

Write \(\hat d\) for the first-stage fitted treatment from projecting \(d\) on \([X,Z]\). Because \(\tilde Z=M_XZ\) is orthogonal to every column of \(X\), the space spanned by \([X,Z]\) is the orthogonal sum of the space spanned by \(X\) and the space spanned by \(\tilde Z\). Therefore the fitted treatment can be written as $$ \hat d=P_Xd+P_{\tilde Z}\tilde d. $$ The first term is the part predicted by the included covariates; the second is the additional fitted variation supplied by the excluded instruments after their covariate-related variation is removed.

The second-stage regression of \(y\) on \(\hat d\) and \(X\) has the same coefficient on \(\hat d\) as the regression of \(M_Xy\) on \(M_X\hat d\) without \(X\). This is the ordinary Frisch–Waugh–Lovell theorem for partial regression. Since \(M_XP_Xd=0\) and \(M_XP_{\tilde Z}\tilde d=P_{\tilde Z}\tilde d\), the residualized fitted treatment is \(P_{\tilde Z}\tilde d\). Thus the second-stage coefficient on treatment is $$ \frac{(P_{\tilde Z}\tilde d)'\tilde y} {(P_{\tilde Z}\tilde d)'(P_{\tilde Z}\tilde d)}. $$ A projection matrix is symmetric and idempotent, so \(P_{\tilde Z}'=P_{\tilde Z}\) and \(P_{\tilde Z}^2=P_{\tilde Z}\). Consequently, the numerator is \(\tilde d'P_{\tilde Z}\tilde y\), and the denominator is \(\tilde d'P_{\tilde Z}\tilde d\). This gives the stated formula.

The derivation shows why all three sets of variables must be handled consistently. Partialling out \(X\) changes the variation in the outcome, treatment, and excluded instruments that is available for the IV calculation. The residualized formulation preserves precisely the variation used by covariate-adjusted 2SLS.

Worked Example: One Instrument and a Group Covariate

Suppose a hypothetical sample contains two groups, with two observations in each group. The outcome \(y\), treatment \(d\), and excluded instrument \(z\) are recorded as follows. The regression includes an intercept and a group indicator, so residualizing on \(X\) is equivalent to subtracting each variable’s group mean.

Group\(y\)\(d\)\(z\)
A13621
A7419
B15831
B5429

For group A, the means are \(10\) for \(y\), \(5\) for \(d\), and \(20\) for \(z\). For group B, they are \(10\), \(6\), and \(30\), respectively. Subtracting the relevant group means gives $$ \tilde y=(3,-3,5,-5)',\qquad \tilde d=(1,-1,2,-2)',\qquad \tilde z=(1,-1,1,-1)'. $$ With one excluded instrument, the coefficient is \(\tilde z'\tilde y/\tilde z'\tilde d\). The numerator is \(3+3+5+5=16\), and the denominator is \(1+1+2+2=6\). Therefore $$ \hat\beta_{\mathrm{2SLS}}=\frac{16}{6}=2.667. $$

In this hypothetical sample, the covariate-adjusted 2SLS estimate is 2.667 outcome units per one-unit increase in treatment. The calculation uses only within-group variation after subtracting the group means. The numerical result alone does not establish that the instrument satisfies the assumptions needed for a causal interpretation.

Worked Example: Two Excluded Instruments Used Jointly

Consider residualized variables from a hypothetical sample with an intercept among the included covariates. Let the two residualized excluded instruments be \(\tilde z_1=(1,-1,0,0)'\) and \(\tilde z_2=(0,0,1,-1)'\). These vectors are orthogonal and each has squared length 2. Suppose the residualized treatment and outcome are \(\tilde d=(5,1,-2,-4)'\) and \(\tilde y=(8,2,-1,-9)'\). Both are centered, as required after residualizing on the intercept.

The treatment’s projection onto the joint instrument space is \(P_{\tilde Z}\tilde d=2\tilde z_1+\tilde z_2\): its inner products with \(\tilde z_1\) and \(\tilde z_2\) are \(4\) and \(2\), respectively, and dividing each by the instruments’ squared length \(2\) gives coefficients \(2\) and \(1\). Likewise, \(\tilde z_1'\tilde y=6\) and \(\tilde z_2'\tilde y=8\), so \(P_{\tilde Z}\tilde y=3\tilde z_1+4\tilde z_2\). The 2SLS formula then gives $$ \hat\beta_{\mathrm{2SLS}} = \frac{(2\tilde z_1+\tilde z_2)'(3\tilde z_1+4\tilde z_2)} {(2\tilde z_1+\tilde z_2)'(2\tilde z_1+\tilde z_2)} = \frac{2(2)(3)+2(1)(4)}{2(2^2)+2(1^2)} = \frac{20}{10} = 2. $$

The two instruments contribute through their joint projection of the residualized treatment and outcome. The answer is not obtained by averaging two separate ratios, nor by adding the instruments’ individual ratios. With multiple instruments, it is their combined instrument space that defines the 2SLS calculation.

Worked Example: Residualizing on a Continuous Covariate

A hypothetical four-observation sample includes a continuous covariate \(x\). The observed data are:

Observation\(x\)\(y\)\(d\)\(z\)
1-396742
2-182346
311081352
431141760

The included covariate matrix \(X\) contains an intercept and \(x\). To calculate residuals, note that the fitted linear components are \(100+4x\) for \(y\), \(10+2x\) for \(d\), and \(50+3x\) for \(z\). Subtracting these fitted values from the observations gives $$ \tilde y=(8,-14,4,2)',\qquad \tilde d=(3,-5,1,1)',\qquad \tilde z=(1,-1,-1,1)'. $$ For example, the residualized outcome for observation 2 is \(82-[100+4(-1)]=-14\). These residuals are orthogonal to the intercept and \(x\); for instance, \((-3)(8)+(-1)(-14)+(1)(4)+(3)(2)=0\).

There is one excluded instrument, so the adjusted coefficient is $$ \hat\beta_{\mathrm{2SLS}} = \frac{\tilde z'\tilde y}{\tilde z'\tilde d} = \frac{8+14-4+2}{3+5-1+1} = \frac{20}{8} = 2.500. $$

The estimated coefficient is 2.500 outcome units per treatment unit, conditional on the linear adjustment for \(x\). This example illustrates that partialling out applies to continuous covariates as well as group indicators: each variable is residualized using its own linear projection on the same included covariate matrix.

Common Mistakes and Practical Meaning

A common mistake is to residualize the treatment on \(X\) but leave the outcome or excluded instruments unadjusted, then apply an IV formula to this mixture. That does not implement the theorem: the formula requires \(\tilde y\), \(\tilde d\), and \(\tilde Z\), all residualized on the same \(X\). Another mistake is to residualize the excluded instruments and then omit the covariates from the original regression without also residualizing the outcome and treatment. The equivalent residualized regression is a coordinated transformation, not a license to remove covariates selectively.

A further pitfall arises with multiple instruments. The correct projection is onto the column space of all residualized excluded instruments together. Calculating separate IV estimates and taking their unweighted average generally does not reproduce 2SLS. The projection formula makes the distinction explicit: \(P_{\tilde Z}\) depends on the joint instrument space.

Partialling out is useful for understanding adjusted 2SLS, checking calculations, and implementing the estimator in settings where removing covariate relationships first is convenient. The equivalence is algebraic. Causal interpretation still depends on the substantive IV assumptions, and the result does not change the need to include the intended covariates in the model. It also concerns the coefficient estimate only; uncertainty calculations require appropriate 2SLS inference rather than treating the two-stage procedure as an ordinary regression with an observed treatment.

Key takeaway: To obtain the covariate-adjusted 2SLS coefficient on treatment, residualize the outcome, treatment, and every excluded instrument on the included exogenous covariates, then estimate IV using the residualized instruments. The coefficient is unchanged because this operation removes the covariate component from both stages consistently.

Check Your Understanding

Use the definitions and result in this tutorial to answer the following.

  1. In a covariate-adjusted IV model, which variables must be residualized on the included covariates before applying the residualized 2SLS formula?
  2. Why does the 2SLS coefficient not change when the covariates are partialled out in both stages?
  3. With one residualized excluded instrument, what ratio gives the treatment coefficient?
  4. With multiple excluded instruments, why must their joint projection be used rather than averaging separate IV estimates?
  5. Does the partialling-out equivalence establish that an excluded instrument is valid? Explain briefly.
Clinical Biostats