Tutorials › Propensity Score Matching and Instrumental Variables › The Naive Second-Stage Standard Error Pitfall

Two-Stage Least Squares · Tutorial 506 of 699

The Naive Second-Stage Standard Error Pitfall

Learn why a fitted-values regression can give the 2SLS coefficient but the wrong standard error, and how to calculate conventional and heteroskedasticity-robust 2SLS covariance estimates.

Advanced 14 min read

What You'll Learn

  • Distinguish the 2SLS coefficient calculation from the ordinary OLS standard error calculation on fitted regressors.
  • Identify the structural residuals and instrument-weighted score terms needed for 2SLS covariance estimates.
  • Calculate the conventional homoskedastic 2SLS covariance estimate and state its assumptions.
  • Calculate the heteroskedasticity-robust 2SLS sandwich estimate.
  • Diagnose when a second-stage standard error is using the wrong residuals or design matrix.
  • Explain why small-sample corrections do not repair an incorrectly constructed covariance estimate.

Why the Second-Stage Standard Error Is a Separate Problem

In two-stage least squares (2SLS), first-stage fitted values are used to isolate the variation in regressors explained by the instruments. Regressing the outcome on those fitted values can reproduce the 2SLS coefficient. That algebraic equivalence does not make the ordinary OLS standard error from that regression a valid 2SLS standard error.

The distinction matters because the original regressor may be endogenous: it may be correlated with the structural error. The fitted regressor is estimated from the instruments, and the outcome’s residual in a regression on fitted values is generally not the structural residual. A valid 2SLS covariance estimate must account for the instrument-based estimation and use the structural residuals in its variance calculation.

Definition: Let \(y\) be an \(n\times1\) outcome vector, \(X\) an \(n\times k\) matrix of regressors (including endogenous regressors and any included exogenous controls), and \(Z\) an \(n\times L\) matrix of instruments (including the included exogenous controls). Define \(P_Z=Z(Z'Z)^{-1}Z'\), assuming \(Z\) has full column rank. The 2SLS estimator is $$ \hat{\beta}_{2SLS}=(X'P_ZX)^{-1}X'P_Zy. $$ The fitted regressor matrix is \(\hat{X}=P_ZX\). The structural residuals are \(\hat{u}=y-X\hat{\beta}_{2SLS}\); the residuals from an OLS regression on fitted regressors are \(\tilde{u}=y-\hat{X}\hat{\beta}_{2SLS}\). In general, \(\hat{u}\ne\tilde{u}\).

This setup presumes instrument validity and identification: instruments must satisfy the required orthogonality conditions with the structural error, and \(X'P_ZX\) must be invertible. For the usual independent-observation asymptotic arguments, the observations must also satisfy suitable sampling and moment conditions. These conditions concern the IV model; computing a standard error does not establish that the instruments are valid or sufficiently informative.

Why the Point Estimates Agree but the OLS Standard Errors Do Not

Since \(P_Z\) is symmetric and idempotent, \(\hat{X}'\hat{X}=X'P_ZX\) and \(\hat{X}'y=X'P_Zy\). Thus an OLS regression of \(y\) on all columns of \(\hat{X}\), with the same treatment of included controls and intercepts as the 2SLS specification, has coefficient $$ (\hat{X}'\hat{X})^{-1}\hat{X}'y=(X'P_ZX)^{-1}X'P_Zy. $$ This equality explains why the reported coefficient can look right. It says nothing by itself about the OLS regression’s estimated variance.

An ordinary OLS covariance calculation treats \(\hat{X}\) as the design matrix for an OLS model and uses the residuals \(\tilde{u}\). But the IV model is \(y=X\beta+u\), so the residuals estimating the structural errors are \(\hat{u}=y-X\hat{\beta}_{2SLS}\). The valid IV covariance also reflects the instrument-weighted estimating equation. Merely substituting fitted regressors into OLS does not generally accomplish either task.

Worked Example: Same Coefficient, Different HC0 Standard Error

Consider a hypothetical just-identified model with no intercept, one endogenous regressor, and one instrument. Let \(z=(1,2,1)'\), \(x=(1,0,0)'\), and \(y=(1,1,0)'\). For this illustration, \(P_Z=zz'/(z'z)\), and \(z'z=6\).

The first-stage fitted regressor is $$ \hat{x}=P_Zx=z\frac{z'x}{z'z} =(1,2,1)'\frac{1}{6} =(1/6,1/3,1/6)'. $$ The 2SLS coefficient is \(\hat{\beta}_{2SLS}=3\). Equivalently, the fitted-values OLS calculation gives $$ \frac{\hat{x}'y}{\hat{x}'\hat{x}} =\frac{1/6+1/3}{1/36+1/9+1/36} =\frac{1/2}{1/6}=3. $$

The residuals in that fitted-values regression are $$ \tilde{u}=y-3\hat{x}=(1/2,0,-1/2)'. $$ Its OLS HC0 variance estimate is $$ \frac{\sum_i\hat{x}_i^2\tilde{u}_i^2}{(\hat{x}'\hat{x})^2} =\frac{(1/6)^2(1/2)^2+(1/3)^2(0)^2+(1/6)^2(-1/2)^2}{(1/6)^2} =\frac{1/72}{1/36}=\frac{1}{2}. $$ The resulting standard error is \(\sqrt{1/2}\approx0.7071\). It is an OLS HC0 calculation for the fitted-values regression, not the 2SLS robust standard error.

The structural residuals instead are \(\hat{u}=y-x(3)=(-2,1,0)'\). The difference between these residual vectors is consequential: they enter different covariance calculations. The next section uses the structural residuals and the instruments to form the 2SLS robust estimate.

Valid Covariance Estimates for 2SLS

Under homoskedasticity, the conventional 2SLS covariance estimate is $$ \widehat{\operatorname{Var}}_{\mathrm{hom}}(\hat{\beta}_{2SLS}) =\hat{\sigma}^2(X'P_ZX)^{-1}, $$ where a common estimate is \(\hat{\sigma}^2=\hat{u}'\hat{u}/(n-k)\). This is the conventional homoskedastic 2SLS formula, not a claim that the exact finite-sample variance conditional on \(Z\) equals that expression. Because \(X\) can be endogenous, treating it as fixed when deriving a conditional variance is generally unjustified. The formula is used under homoskedastic IV conditions as a conventional estimate and has the corresponding large-sample justification under standard IV regularity conditions.

For independent observations with heteroskedastic errors, a sandwich estimate is $$ \widehat{\operatorname{Var}}_{\mathrm{rob}}(\hat{\beta}_{2SLS}) =(X'P_ZX)^{-1} \left[ X'Z(Z'Z)^{-1} \left(\sum_{i=1}^{n}z_i z_i'\hat{u}_i^2\right) (Z'Z)^{-1}Z'X \right] (X'P_ZX)^{-1}, $$ where \(z_i'\) is row \(i\) of \(Z\), and \(\hat{u}_i\) is the \(i\)th structural residual. Equivalently, the middle matrix is \(X'P_Z\operatorname{diag}(\hat{u}_i^2)P_ZX\). This form shows both essential ingredients: structural residuals and instrument-weighted scores. The square roots of the diagonal entries of the estimated covariance matrix are the standard errors.

Worked Example: Calculate the Robust 2SLS Standard Error

Continue the hypothetical data above. There is one coefficient, so \(X'P_ZX=x'P_Zx=(z'x)^2/(z'z)=1/6\), and its inverse is \(6\). The structural residuals are \((-2,1,0)'\), while the fitted regressor is \((1/6,1/3,1/6)'\).

For this one-regressor calculation, the robust “meat” is the sum of squared fitted-regressor values multiplied by squared structural residuals: $$ \sum_i\hat{x}_i^2\hat{u}_i^2 =(1/6)^2(-2)^2+(1/3)^2(1)^2+(1/6)^2(0)^2 =\frac{1}{9}+\frac{1}{9}+0=\frac{2}{9}. $$

Correction: the first term is \(4/36=1/9\), the second is \(1/9\), so the sum is \(2/9\). The sandwich variance is therefore $$ 6^2\left(\frac{2}{9}\right)=8, $$ and the robust standard error is \(\sqrt{8}\approx2.828\). This differs from the fitted-values OLS HC0 result because that calculation used \(\tilde{u}\), not \(\hat{u}\). In this deliberately tiny sample, neither asymptotic standard error should be read as precise; the arithmetic illustrates the covariance construction, not a dependable inferential analysis.

The example’s robust variance can also be checked directly from the instrument-score form. Here \(z_i\hat{u}_i\) equals \((-2,2,0)'\), so \(\sum_i z_i^2\hat{u}_i^2=8\). Since \(z'z=6\), the scalar middle term is \(8/6^2=2/9\); multiplying by the two outer factors of \(6\) again gives \(8\). Such checks are useful for catching a common computational error: using instrument values in a fitted-design HC0 formula, or fitted-design residuals in the IV sandwich.

Worked Example: Conventional Homoskedastic Estimate

For the same data, \(\hat{u}'\hat{u}=(-2)^2+1^2+0^2=5\). With \(n=3\) observations and \(k=1\) estimated structural coefficient, the common residual variance estimate is $$ \hat{\sigma}^2=\frac{5}{3-1}=2.5. $$

The conventional homoskedastic 2SLS variance estimate is $$ \hat{\sigma}^2(X'P_ZX)^{-1}=2.5(6)=15, $$ so the standard error is \(\sqrt{15}\approx3.873\). This is not an exact conditional sampling standard deviation. It is the conventional estimate under the specified homoskedastic approach, and its small-sample behavior in this three-observation illustration is especially poor.

How to Choose and Check the Calculation

The covariance estimator should match the error dependence structure and sampling design. The conventional homoskedastic formula relies on a homoskedastic specification. If error variance may differ across independent observations, use the heteroskedasticity-robust 2SLS sandwich. If observations are clustered or serially dependent, use the corresponding cluster-robust or HAC 2SLS covariance estimate rather than treating observations as independent. A finite-sample multiplier can modify a suitable covariance estimate; it cannot turn the wrong OLS covariance formula into a valid IV one.

Before interpreting an estimated standard error, check that the calculation uses the intended model and covariance estimator. In particular:

  • Verify that \(X\) includes all structural regressors and \(Z\) includes the instruments and included exogenous controls.
  • For the robust 2SLS sandwich, verify that residuals are \(y-X\hat{\beta}_{2SLS}\), not \(y-\hat{X}\hat{\beta}_{2SLS}\).
  • Check that the “meat” is based on instrument-weighted residual scores, not the ordinary OLS HC0 meat for the fitted-values regression.
  • Confirm that the chosen covariance estimator reflects heteroskedasticity, clustering, or serial dependence as appropriate.

A large discrepancy between an OLS second-stage standard error and a correctly constructed 2SLS standard error is a reason to inspect the formulas, not a reason to select whichever answer appears more plausible. Conversely, agreement does not validate the naive calculation: different formulas can coincide in special cases or by chance.

Common Mistake and the Main Alternatives

Wrong reasoning: “The regression on first-stage fitted values gives the 2SLS coefficient, so its usual OLS standard error—or its OLS HC0 standard error—must also be the 2SLS standard error.” The conclusion does not follow. Equality of coefficient formulas does not establish equality of their variance estimators. The correction is to use the 2SLS covariance formula appropriate to the sampling assumptions, with the structural residuals and the IV score structure.

The main alternative is to estimate the same IV model using software that reports 2SLS covariance estimates directly, specifying the desired homoskedastic, heteroskedasticity-robust, clustered, or HAC option. This avoids manually reconstructing the sandwich, but the analyst must still verify which estimator the software reports and whether its assumptions fit the data. Ordinary least squares on the original \(X\) is not a substitute when endogeneity is the reason for using instruments. The familiar material on homoskedastic and robust 2SLS inference gives the corresponding covariance choices; here the central issue is why the fitted-values OLS shortcut does not reproduce them.

Key takeaway: The fitted-values OLS regression can reproduce the 2SLS coefficient while producing a generally invalid standard error. For 2SLS inference, use a covariance estimator built for the IV estimating equation; for robust inference, that means structural residuals and instrument-weighted scores.

Check Your Understanding

Answer each question, then compare your reasoning with the brief solutions.

  1. Why can OLS on \(\hat{X}=P_ZX\) give the 2SLS coefficient without giving a valid OLS standard error for that coefficient?
  2. In the one-regressor robust 2SLS sandwich, which residuals are used: \(y-\hat{X}\hat{\beta}_{2SLS}\) or \(y-X\hat{\beta}_{2SLS}\)?
  3. Suppose \(X'P_ZX=10\), \(\hat{\sigma}^2=3\), and there is one coefficient. Calculate the conventional homoskedastic 2SLS variance estimate and standard error.
  4. What should replace the independent-observation robust covariance estimator if observations are clustered?

Solutions. (1) The coefficient equality follows from \(\hat{X}'\hat{X}=X'P_ZX\) and \(\hat{X}'y=X'P_Zy\). The OLS standard error uses the fitted-design regression’s residuals and covariance structure, not the IV sandwich. (2) Use the structural residuals \(y-X\hat{\beta}_{2SLS}\). (3) The variance estimate is \(3(10^{-1})=0.3\), so the standard error is \(\sqrt{0.3}\approx0.5477\). (4) Use a cluster-robust 2SLS covariance estimator that accounts for within-cluster dependence.

Clinical Biostats