Why 2SLS Needs a Robust Variance Estimate
Two-stage least squares (2SLS) estimates a structural relationship using variation in regressors predicted by instruments. Its coefficient estimate does not require the outcome error to have the same variance for every observation. But the usual homoskedastic variance formula does make that assumption. If the error variance differs across observations, that formula can misstate the sampling uncertainty of the 2SLS estimate.
The heteroskedasticity-robust variance estimator replaces the common error variance with a sum of observation-level contributions. Each contribution combines that observation’s squared 2SLS residual with its instrument values. The resulting estimator is often called a sandwich estimator because it has a middle “meat” matrix between two “bread” matrices.
Model and Assumptions
Let \(y\) be an \(n \times 1\) vector of outcomes, \(X\) an \(n \times K\) matrix of structural regressors, and \(Z\) an \(n \times L\) matrix of instruments, where \(L \geq K\). The structural model is
Here \(\beta\) is the \(K \times 1\) coefficient vector and \(u\) is the \(n \times 1\) error vector. The rows of \(X\) and \(Z\) are \(x_i'\) and \(z_i'\). The regressors may include endogenous variables; any included exogenous regressors should also be included among the instruments. Assume that \(Z\) has full column rank and that \(X'P_ZX\) is invertible, where
The 2SLS estimator is
For the robust variance estimator to be justified, the instruments must satisfy the relevant exogeneity moments, such as \(E[z_i u_i]=0\), and provide enough identifying variation for the coefficient vector. The observations are assumed independent, with suitable finite moments and a stable, nonsingular identification structure. Their error variances need not be equal: conditional on the instruments and regressors, \(\operatorname{Var}(u_i\mid Z,X)\) may differ from one observation to another. Independence matters here; allowing unequal variances is not the same as allowing arbitrary dependence across observations.
The Sandwich Formula
Let \(\hat u=y-X\hat{\beta}_{2SLS}\), with \(i\)th residual \(\hat u_i\). A common heteroskedasticity-robust estimator, often called the HC0 form, is
The middle matrix is the estimated “meat.” It sums the outer product \(z_i z_i'\) for each observation, weighted by that observation’s squared residual. The two surrounding parts are the “bread.” Because this is a matrix, its diagonal entries estimate the variances of the coefficient estimates, while its off-diagonal entries estimate their covariances.
The 2SLS estimating equation gives a short justification for this form. Substituting \(y=X\beta+u\) into the estimator yields
With \(X\) and \(Z\) treated as fixed, the middle random quantity is a linear combination of the errors. If the errors are independent but have different conditional variances, then
Premultiplying and postmultiplying this expression by the coefficient matrices in the equation for \(\hat{\beta}_{2SLS}-\beta\) gives the sandwich structure. Replacing the unknown error variances by squared residuals gives the displayed estimator. Under the stated regularity conditions, this estimates the sampling variance consistently as the sample grows; it is not generally an exactly unbiased finite-sample variance estimate.
Connection to the Homoskedastic Formula
If the errors instead have a common conditional variance, \(\operatorname{Var}(u_i\mid X,Z)=\sigma^2\), then the middle population quantity is \(\sigma^2 Z'Z\). Substitution into the sandwich expression reduces it to
This is the homoskedastic 2SLS variance formula. Its usual estimated version replaces \(\sigma^2\) with a residual variance estimate, commonly \(\hat{\sigma}^2=\hat u'\hat u/(n-K)\). The robust formula does not make that common-variance substitution: it retains the observation-specific squared residuals inside the meat. Even if the two estimators happen to be similar in a particular sample, they rely on different variance assumptions.
Worked Example: Comparing Robust and Homoskedastic Standard Errors
Consider a hypothetical just-identified model with one regressor and one instrument, with no intercept. The observations are shown below. For this calculation, assume the instrument is valid and the identification conditions hold; the table alone cannot establish those assumptions.
| Observation | \(z_i\) | \(x_i\) | \(y_i\) |
|---|---|---|---|
| 1 | -1 | 1 | 2 |
| 2 | -1 | 2 | 1 |
| 3 | 1 | 3 | 5 |
| 4 | 1 | 4 | 6 |
In this scalar just-identified case, the 2SLS estimate is \(\hat{\beta}_{2SLS}=\sum_i z_i y_i/\sum_i z_i x_i\). Substituting the data gives
The residuals are \(\hat u_i=y_i-2x_i\), which gives \(0,-3,-1,-2\). The robust variance in this scalar case is
Thus the robust standard error is \(\sqrt{0.875}=0.9354\) outcome units per unit of \(x\). For comparison, the residual sum of squares is \(14\), so the conventional homoskedastic residual variance estimate is \(14/(4-1)=4.667\). Also, \(X'P_ZX=(\sum_i z_i x_i)^2/\sum_i z_i^2=16/4=4\). The homoskedastic variance estimate and standard error are therefore
The robust and homoskedastic estimates differ because they weight the observed residuals differently. The robust calculation uses each \(z_i^2\hat u_i^2\), rather than summarizing all residual sizes with a single variance estimate. The difference in this small hypothetical sample does not establish which assumption is appropriate in an application.
Worked Example: Robust Variance With Multiple Instruments
Now consider a hypothetical model with one regressor, no intercept, and two instruments. The instrument rows are \(z_i'=(1,1),(1,-1),(-1,1),(-1,-1)\). Let \(x=(1,2,3,4)'\) and \(y=(3,4,6,8)'\). The instruments are orthogonal in this sample, so \(Z'Z=4I\), where \(I\) is the \(2 \times 2\) identity matrix. The relevant cross-product and projected-regressor quantities are
The outcome cross-product is \(Z'y=(-7,-3)'\). Hence
The residuals \(y_i-1.7x_i\) are \(1,0.6,0.9,1.2\). The bread on one side of the scalar sandwich is
The meat is
For example, its first diagonal entry is \(1^2+0.6^2+0.9^2+1.2^2=3.61\); its off-diagonal entry is \(1^2-(0.6)^2-(0.9)^2+(1.2)^2=1.27\), with signs determined by the paired instrument values. Therefore,
The matrix calculation accounts for both instruments and their covariance contribution in the meat. It does not require that the two instruments be treated as separate coefficient estimates.
Worked Example: Unequal Instrument Values in a Scalar Calculation
A final hypothetical example illustrates why instrument values affect the robust variance. Again use a scalar model with no intercept, now with \(z=(1,2,1,2)'\), \(x=(1,2,2,3)'\), and \(y=(2,5,3,8)'\). The estimate is
The residuals, using the unrounded estimate \(31/13\), are \((-5,3,-23,11)'/13\). The robust variance is
so \(SE_{\mathrm{rob}}=\sqrt{0.03760}=0.1939\). For the homoskedastic comparison, the residual sum of squares is \(684/169\), giving \(\hat{\sigma}^2=(684/169)/3=228/169\). Since \(\sum_i z_i^2=10\), the estimated homoskedastic variance and standard error are
Both calculations use the same 2SLS coefficient, \(2.385\). Their standard errors differ because the robust calculation preserves the association between each squared residual and that observation’s squared instrument value.
What Robust Standard Errors Do—and Do Not—Address
A heteroskedasticity-robust 2SLS standard error is appropriate when independent observations may have unequal error variances and the IV model’s identification and exogeneity conditions are credible. It describes estimated sampling variability under those conditions; it does not validate the instruments. In particular, changing the variance estimator cannot make an instrument exogenous or create identifying information that is absent.
The formula above also relies on independence across observations. If observations are dependent within groups, treating them as independent can still give an inappropriate standard error. Robustness to unequal individual variances should not be confused with robustness to such dependence.
A frequent mistake is to run the second stage using fitted values and then report the ordinary OLS standard error from that regression. The fitted regressor does not make the ordinary second-stage OLS variance formula appropriate for 2SLS. For this tutorial’s focus, the relevant calculation is the 2SLS sandwich: use the original instrument matrix, the structural residuals \(y-X\hat{\beta}_{2SLS}\), and the full bread matrices. A standard error is not chosen by looking at which one is smaller or more convenient; its assumptions must match the sampling structure and model.
Check Your Understanding
Use the formulas and distinctions in this tutorial to answer the following questions.
- In the sandwich formula, what information does the meat matrix contain, and why is it observation-specific?
- Which error-variance assumption leads to the homoskedastic formula \(\sigma^2(X'P_ZX)^{-1}\)?
- In a just-identified scalar model, how would you compute the robust variance from \(z_i\), \(x_i\), and the 2SLS residuals?
- Why can the robust and homoskedastic standard errors differ even though the 2SLS coefficient estimate is the same?
- Does using heteroskedasticity-robust standard errors establish that the instruments are valid? Explain.