Tutorials › Causal Inference › Deriving Homoskedastic 2SLS Variance

Linear IV Estimation · Tutorial 526 of 972

Deriving Homoskedastic 2SLS Variance

See how the 2SLS variance follows from the projection matrix, what homoskedasticity must mean for the derivation, and how to calculate its conventional standard error.

Intermediate 10 min read

What You'll Learn

  • Write the 2SLS estimator and its projected-regressor form.
  • Derive the homoskedastic variance using the projection matrix’s symmetry and idempotence.
  • Distinguish a conditional second-moment assumption from a conditional variance assumption.
  • Calculate the conventional residual-based variance estimate and standard error.
  • Explain why projected treatment variation affects 2SLS precision.
  • Identify when the conventional homoskedastic formula may be inappropriate.

Why 2SLS Needs Its Own Variance Calculation

Two-stage least squares (2SLS) uses the variation in regressors projected onto the instrument space. Its coefficient estimate may be computed through a fitted-regressor representation, but that does not mean the usual second-stage OLS standard error is automatically valid. To obtain the conventional homoskedastic 2SLS variance, we use the 2SLS estimator itself and the assumed covariance structure of the structural errors.

This tutorial derives the finite-sample variance formula under explicit conditional assumptions, then shows how its unknown error variance is conventionally estimated. The same matrix expression is also the familiar large-sample homoskedastic variance estimator under standard IV moment conditions and a constant conditional second moment. Those statements concern related formulas, but their assumptions should not be conflated.

Definition: Let \(y\) be an \(n\)-vector of outcomes, \(X\) an \(n\times K\) matrix of regressors, \(Z\) an \(n\times L\) matrix of instruments, and \(u\) an \(n\)-vector of structural errors. The linear structural equation is \(y=X\beta+u\). If \(Z\) has full column rank, define the projection matrix \(P_Z=Z(Z'Z)^{-1}Z'\). The 2SLS estimator is \(\hat\beta_{2SLS}=(X'P_ZX)^{-1}X'P_Zy\), provided \(X'P_ZX\) is nonsingular.

The matrix \(P_Z\) is symmetric and idempotent: \(P_Z'=P_Z\) and \(P_ZP_Z=P_Z\). The projected regressor matrix is \(\hat X=P_ZX\). Thus \(X'P_ZX=\hat X'\hat X\), and the 2SLS estimator can be written as \((\hat X'\hat X)^{-1}\hat X'y\). This representation is useful for deriving the variance, but \(\hat X\) is constructed from instruments and is not a license to treat the second stage as ordinary OLS with fixed regressors in every respect.

Assumptions for the Homoskedastic Formula

For the exact conditional variance derivation below, regard the design matrices \(X\) and \(Z\) as fixed, or condition on them. Require that \(X'P_ZX\) is nonsingular and that the errors have conditional mean zero and conditional covariance matrix \(\sigma^2 I_n\). The latter says that, given the design, each error has variance \(\sigma^2\) and distinct errors have zero conditional covariance. Conditional independence with a common finite variance is one sufficient way to obtain this covariance structure; independence is stronger than the derivation requires.

Assumption: For the finite-sample conditional variance result, \(E[u\mid X,Z]=0\) and \(\operatorname{Var}(u\mid X,Z)=\sigma^2I_n\), where \(\sigma^2\) is constant. The first condition centers the errors; the second specifies their conditional covariance. In the usual IV setup, instrument validity is often stated as a moment restriction such as \(E[Z_i u_i]=0\). That unconditional restriction alone does not imply \(E[u_i\mid Z_i]=0\).

A related asymptotic formulation is worth distinguishing. With independent observations and the IV moment condition \(E[Z_i u_i]=0\), a constant conditional second moment \(E[u_i^2\mid Z_i]=\sigma^2\) yields the homoskedastic simplification of the large-sample IV sandwich variance. Here “second moment” is deliberate: it is not generally the same as conditional variance. The equality \(E[u_i^2\mid Z_i]=\operatorname{Var}(u_i\mid Z_i)\) holds only if \(E[u_i\mid Z_i]=0\). The finite-sample derivation in the next section instead explicitly assumes conditional mean zero and a conditional covariance matrix of \(\sigma^2 I_n\).

Deriving the Conditional Variance

Substitute the structural equation \(y=X\beta+u\) into the 2SLS estimator. The resulting estimation error is a linear transformation of \(u\). Applying the conditional covariance rule to that transformation gives the variance formula.

$$ \begin{aligned} \hat\beta_{2SLS} &=(X'P_ZX)^{-1}X'P_Z(X\beta+u)\\ &=\beta+(X'P_ZX)^{-1}X'P_Zu. \end{aligned} $$

Because \(E[u\mid X,Z]=0\), the conditional expectation of \(\hat\beta_{2SLS}\) is \(\beta\). Its conditional variance is therefore the conditional covariance of the linear error term. Write \(A=(X'P_ZX)^{-1}X'P_Z\). Then \(\hat\beta_{2SLS}-\beta=Au\), so \(\operatorname{Var}(\hat\beta_{2SLS}\mid X,Z)=A\operatorname{Var}(u\mid X,Z)A'\). Use \(\operatorname{Var}(u\mid X,Z)=\sigma^2I_n\), the symmetry of \(P_Z\), and its idempotence:

$$ \begin{aligned} \operatorname{Var}(\hat\beta_{2SLS}\mid X,Z) &=\sigma^2(X'P_ZX)^{-1}X'P_ZP_ZX(X'P_ZX)^{-1}\\ &=\sigma^2(X'P_ZX)^{-1}X'P_ZX(X'P_ZX)^{-1}\\ &=\sigma^2(X'P_ZX)^{-1}. \end{aligned} $$

The last equality uses the nonsingularity of \(X'P_ZX\). This derivation is the reason the projected-regressor matrix appears in the conventional variance formula: \(P_ZP_Z=P_Z\) reduces the middle product to \(X'P_ZX\). The result is a \(K\times K\) matrix. Its diagonal entries are conditional variances of the coefficient estimates; off-diagonal entries are their conditional covariances.

Theorem: Under the stated conditional mean and covariance assumptions and the rank conditions, \(\operatorname{Var}(\hat\beta_{2SLS}\mid X,Z)=\sigma^2(X'P_ZX)^{-1}\). For scalar \(\beta\), this reduces to \(\sigma^2/(x'P_Zx)\), where \(x\) is the \(n\)-vector of regressors.

From the Formula to a Standard Error

The error variance \(\sigma^2\) is unknown. A conventional estimate uses the structural residuals \(\hat u=y-X\hat\beta_{2SLS}\) and sets \(\hat\sigma^2=\hat u'\hat u/(n-K)\). The resulting homoskedastic covariance estimator is \(\widehat{\operatorname{Var}}(\hat\beta_{2SLS})=\hat\sigma^2(X'P_ZX)^{-1}\). This residual-based estimate of \(\sigma^2\) is commonly used and is consistent under standard conditions, but with 2SLS it is not generally an exactly unbiased finite-sample estimate. The degrees of freedom \(n-K\) account for the number of structural coefficients estimated.

Worked Example: Variance From a Projected Regressor

Suppose a hypothetical scalar-regressor 2SLS analysis has projected regressor \(\hat x=P_Zx=(2,-1,1,0)'\). Assume the error variance is known to be \(\sigma^2=4\). Find the conditional variance and standard error of the coefficient estimate.

Since \(P_Z\) is symmetric and idempotent, \(x'P_Zx=(P_Zx)'(P_Zx)=\hat x'\hat x\). Thus the denominator is \(2^2+(-1)^2+1^2+0^2=6\).

$$ \operatorname{Var}(\hat\beta_{2SLS}\mid X,Z) =\frac{\sigma^2}{x'P_Zx} =\frac{4}{6} =0.6667, \qquad SE(\hat\beta_{2SLS}\mid X,Z)=\sqrt{0.6667}=0.8165. $$

The coefficient’s standard error is 0.8165 in the units of the outcome per unit of the regressor. This calculation isolates how the projected regressor enters the variance; in applications, \(\sigma^2\) must also be estimated.

Worked Example: Calculating a Residual-Based 2SLS Standard Error

Consider a hypothetical model with no intercept, one structural regressor, four observations, and two instruments. Let the two instrument columns be \(z_1=(1,1,1,1)'\) and \(z_2=(1,-1,1,-1)'\). They are orthogonal and each has squared length 4. Suppose \(x=(3,1,2,0)'\) and \(y=(5,2,4,1)'\). Compute the 2SLS coefficient and conventional homoskedastic standard error.

The projection of \(x\) onto the instrument columns has mean component \(1.5\) and \(z_2\) component \(1\), since \(z_1'x/4=6/4=1.5\) and \(z_2'x/4=4/4=1\). Hence \(P_Zx=(2.5,0.5,2.5,0.5)'\). Similarly, \(z_1'y/4=12/4=3\) and \(z_2'y/4=6/4=1.5\), so \(P_Zy=(4.5,1.5,4.5,1.5)'\).

For a single structural regressor, \(\hat\beta_{2SLS}=x'P_Zy/(x'P_Zx)\). The denominator is \(3(2.5)+1(0.5)+2(2.5)+0(0.5)=13\). The numerator is \(3(4.5)+1(1.5)+2(4.5)+0(1.5)=24\). Therefore \(\hat\beta_{2SLS}=24/13=1.846\) outcome units per unit of \(x\).

The structural residuals are \(\hat u=y-x\hat\beta_{2SLS}=(-7/13,\,2/13,\,4/13,\,1)'\). Their squared sum is \(\hat u'\hat u=(49+4+16)/169+1=238/169=1.408\). There are \(n-K=4-1=3\) residual degrees of freedom, so \(\hat\sigma^2=(238/169)/3=238/507=0.4694\).

$$ \widehat{\operatorname{Var}}(\hat\beta_{2SLS}) =\frac{0.4694}{13} =0.03611, \qquad SE(\hat\beta_{2SLS})=\sqrt{0.03611}=0.1900. $$

The computed conventional homoskedastic standard error is 0.1900 outcome units per unit of \(x\). The calculation assumes the specified instrument matrix has full rank, \(x'P_Zx=13>0\), and the homoskedastic covariance model is appropriate. These data are hypothetical and illustrate the arithmetic, not an empirical conclusion.

How Projected Variation Affects Precision

In the scalar case, the variance is \(\sigma^2/(x'P_Zx)\). Holding the error variance fixed, a larger \(x'P_Zx\) means a smaller conditional variance. Because \(x'P_Zx=(P_Zx)'(P_Zx)\), this denominator measures the squared length of the component of the regressor that lies in the instrument space. It is not simply the total variation in \(x\); variation in \(x\) outside that space does not contribute to this denominator.

Worked Example: Comparing Two Projected-Variation Levels

Suppose two hypothetical scalar 2SLS designs have the same estimated error variance, \(\hat\sigma^2=1.44\), but different values of \(x'P_Zx\). Design A has \(x'P_Zx=8\), while Design B has \(x'P_Zx=32\). Compare their conventional standard errors.

For Design A, \(\widehat{\operatorname{Var}}(\hat\beta)=1.44/8=0.18\), giving \(SE=\sqrt{0.18}=0.4243\). For Design B, \(\widehat{\operatorname{Var}}(\hat\beta)=1.44/32=0.045\), giving \(SE=\sqrt{0.045}=0.2121\).

Under this formula, Design B’s standard error is half Design A’s because its projected-regressor squared length is four times as large, while the estimated error variance is unchanged. This is a comparison of the formula’s precision component, not by itself a claim that either design meets all IV identification or validity conditions.

Common Mistakes and Scope

  • Using the second-stage OLS standard error without justification. The conventional 2SLS variance follows from the 2SLS estimator and the assumed error covariance structure. Treating fitted regressors as if they were ordinary observed regressors does not establish that the usual second-stage OLS standard error is valid.
  • Calling a conditional second moment a conditional variance. \(E[u_i^2\mid Z_i]=\sigma^2\) is a constant conditional second-moment assumption. It equals \(\operatorname{Var}(u_i\mid Z_i)\) only when \(E[u_i\mid Z_i]=0\). Instrument validity in the form \(E[Z_i u_i]=0\) does not by itself supply that conditional mean-zero condition.
  • Assuming the residual-based \(\hat\sigma^2\) is exactly unbiased. The conventional estimator \(\hat u'\hat u/(n-K)\) is a standard plug-in estimate, but 2SLS residuals do not generally make this exact finite-sample unbiasedness claim true.
  • Reading \(x'P_Zx\) as total regressor variation. It is the squared length of the projected regressor. The formula’s precision depends on instrument-projected variation, not on every component of \(x\).

The homoskedastic expression is appropriate only when its covariance assumptions are defensible for the analysis. If error variability differs across observations, the simplification to \(\hat\sigma^2(X'P_ZX)^{-1}\) need not provide the appropriate variance estimate. The central lesson here is to connect the standard error to the assumptions that produced it, rather than selecting it solely because a software output labels it “2SLS.”

Check Your Understanding

Use the derivation and examples to answer the following questions.

  1. Which two projection-matrix properties simplify the 2SLS variance expression, and where are they used?
  2. For a scalar regressor, if \(\hat\sigma^2=2.25\) and \(x'P_Zx=9\), calculate the conventional variance estimate and standard error.
  3. Why does \(E[u_i^2\mid Z_i]=\sigma^2\) not, by itself, mean that \(\operatorname{Var}(u_i\mid Z_i)=\sigma^2\)?
  4. In the residual-based estimate, why is the denominator \(n-K\), and why should that not be taken as proof of exact finite-sample unbiasedness?
  5. Under the scalar formula, what happens to the standard error if \(x'P_Zx\) is multiplied by four while \(\hat\sigma^2\) stays fixed?
Clinical Biostats