Sandwich Variance
& Robust SE
Understand why classical standard errors fail under heteroskedasticity and how the sandwich estimator provides robust inference without assuming a specific error structure.
Why Do We Need Robust Standard Errors?
In ordinary least squares (OLS), we estimate \(\hat{\beta} = (X'X)^{-1}X'y\). The classical variance formula assumes homoskedastic errors:
Homoskedasticity vs Heteroskedasticity
The True Variance of \(\hat{\beta}\)
Without assuming homoskedasticity, the variance of the OLS estimator is:
where \(\Omega = \text{Var}(\varepsilon \mid X)\) is the \(n \times n\) covariance matrix of errors. Under homoskedasticity, \(\Omega = \sigma^2 I\) and this reduces to the classical form. Otherwise, we need the full sandwich.
Anatomy of the Sandwich
The HC0 Estimator (White, 1980)
Halbert White proposed replacing \(\Omega\) with a diagonal matrix of squared OLS residuals:
HC Estimator Variants
Several corrections improve finite-sample performance by adjusting the squared residuals \(e_i^2\):
| Variant | Residual Weight | Key Idea |
|---|---|---|
| HC0 | \(e_i^2\) | No correction |
| HC1 | \(\frac{n}{n-k}\,e_i^2\) | Degrees-of-freedom correction |
| HC2 | \(\frac{e_i^2}{1-h_{ii}}\) | Leverage-based correction |
| HC3 | \(\frac{e_i^2}{(1-h_{ii})^2}\) | Jackknife-like (most conservative) |
Classical vs Robust SE
| Feature | Classical SE | Robust SE |
|---|---|---|
| Assumes | \(\text{Var}(\varepsilon_i) = \sigma^2\) | No restriction on \(\text{Var}(\varepsilon_i)\) |
| Formula | \(\hat{\sigma}^2(X'X)^{-1}\) | \((X'X)^{-1}\hat{M}(X'X)^{-1}\) |
| If homoskedastic | Efficient, correct | Correct, slightly less efficient |
| If heteroskedastic | Biased, invalid tests | Consistent, valid tests |
| Small-sample | Exact (under normality) | Approximate: improves with \(n\) |
How to Apply Robust SE
Example: Simple Regression
Suppose we regress income on education with \(n=5\) observations and \(k=2\) (intercept + slope). OLS gives \(\hat{\beta}_1 = 2.3\) with residuals:
| \(i\) | \(x_i\) | \(e_i\) | \(e_i^2\) |
|---|---|---|---|
| 1 | 10 | -1.2 | 1.44 |
| 2 | 12 | 0.8 | 0.64 |
| 3 | 14 | 1.8 | 3.24 |
| 4 | 16 | 2.1 | 4.41 |
| 5 | 18 | -3.5 | 12.25 |
Example: Computing HC1
Using HC1 with the degree-of-freedom correction \(\frac{n}{n-k} = \frac{5}{3}\):
Example: When SE Flips
Robust SE can be larger or smaller than classical SE depending on the pattern of heteroskedasticity:
Beyond HC: Clustered Robust SE
When observations are grouped (students within schools, patients within hospitals), errors may be correlated within clusters even if uncorrelated across clusters:
The General Principle
Common Mistakes
Summary and Quick Reference
| Concept | Key Formula / Idea |
|---|---|
| Sandwich form | \((X'X)^{-1}(X'\hat{\Omega}X)(X'X)^{-1}\) |
| HC0 (White) | Meat uses \(e_i^2\): no correction |
| HC1 | Multiply by \(\frac{n}{n-k}\): d.f. correction |
| HC2 | Divide \(e_i^2\) by \(1-h_{ii}\): leverage |
| HC3 | Divide \(e_i^2\) by \((1-h_{ii})^2\): jackknife-like |
| Clustered SE | Sum meat over clusters \(g\) |
| When to use | Default in applied work; essential when heteroskedasticity is suspected |
Question 1 of 5
In the sandwich variance estimator \((X'X)^{-1}\hat{M}(X'X)^{-1}\), the "meat" \(\hat{M}\) primarily captures information about:
Question 2 of 5
Under homoskedasticity, what happens when you use robust (HC) standard errors instead of classical SE?
Question 3 of 5
Which HC variant is recommended for small samples with observations that have varying leverage?
Question 4 of 5
A researcher runs OLS and finds that the robust standard error for \(\hat{\beta}_1\) is smaller than the classical SE. Which of the following is the best interpretation?
Question 5 of 5
When should you use clustered standard errors instead of heteroskedasticity-robust (HC) standard errors?