Why Adjust Residuals for Leverage?
OLS residuals are not the unobserved regression errors themselves. Because the fitted regression is estimated from the same observations, each observation helps determine its own fitted value. An observation with high regression leverage can therefore have a residual that is especially constrained by the fitting process. If squared residuals are used directly to estimate the error contribution to a robust covariance matrix, this shrinkage can matter, particularly in a small sample.
HC2 addresses this issue by dividing each squared residual by one minus that observation’s leverage. The correction is larger when leverage is higher. Its simplest justification comes from a homoskedastic model, where the expected squared residual has a precise leverage-dependent shrinkage factor. Under heteroskedasticity, the same adjustment remains a useful leverage correction, but it is not generally an exact, observation-by-observation correction for the conditional error variance.
Model, Leverage, and the HC2 Estimator
Let \(y\) be an \(n\)-vector of outcomes and \(X\) an \(n\times k\) design matrix of full column rank, including an intercept if the model has one. Write the linear model as \(y=X\beta+u\). For the conditional calculations below, assume \(E(u\mid X)=0\). Define the projection matrix \(H=X(X'X)^{-1}X'\), the residual-maker matrix \(M=I-H\), the OLS residual vector \(e=My\), and the leverage of observation \(i\) as \(h_{ii}=H_{ii}\). With full column rank, \(0\leq h_{ii}\leq1\), and the leverages sum to \(k\).
The adjustment is well-defined when \(h_{ii}<1\). If \(h_{ii}=1\), then \(1-h_{ii}=0\): that observation is perfectly fitted in the direction represented by the design, and the HC2 formula cannot be applied to its residual. In an ordinary nonsaturated regression with usable residual information, the relevant leverages are below one.
The “HC” label indicates a heteroskedasticity-consistent covariance estimator. HC2 changes the observation-level squared residuals in the sandwich covariance estimator; it does not change the OLS coefficient estimates. Unlike the HC1 degrees-of-freedom scaling, HC2 makes an observation-specific adjustment determined by its leverage.
Why the Residual Is Shrunk
The key result requires care about the error assumptions. Suppose errors have conditional mean zero, are conditionally uncorrelated across observations, and have a common conditional variance: \(E(u\mid X)=0\), \(E(u_i u_j\mid X)=0\) for \(i\ne j\), and \(E(u_i^2\mid X)=\sigma^2\) for every \(i\). Then the conditional covariance matrix of \(u\) is \(\sigma^2 I\). Since \(e=Mu\), the expected squared residual is
The middle equality follows because \(M\) is symmetric and idempotent: \(M'=M\) and \(M^2=M\). Thus \(\sum_j M_{ij}^2=(MM')_{ii}=(M^2)_{ii}=M_{ii}\), while \(M_{ii}=1-H_{ii}=1-h_{ii}\). Dividing \(e_i^2\) by \(1-h_{ii}\) removes this particular expected shrinkage: under these homoskedastic conditions, \(E\{e_i^2/(1-h_{ii})\mid X\}=\sigma^2\).
This is a conditional result, not a consequence of equal variances alone. If errors are correlated, off-diagonal terms in the conditional covariance matrix also affect \(E(e_i^2\mid X)\); the formula above need not hold. This distinction matters because HC2 is motivated by residual shrinkage, but its simple exact justification depends on the stated conditions.
Worked Example: Adjusting Residual Squares at Different Leverages
Consider five hypothetical observations in a regression of \(y\) on an intercept and \(x\). Let the \(x\) values be \(-2,-1,0,1,2\), and suppose the observed outcomes are \(7,7,10,11,15\). The fitted line is \(\hat{y}=10+2x\), giving residuals \(1,-1,0,-1,1\). These are valid OLS residuals: their sum is zero, and their product-sum with \(x\) is \((-2)(1)+(-1)(-1)+(1)(-1)+(2)(1)=0\).
For this design, \(\bar{x}=0\) and \(\sum_i(x_i-\bar{x})^2=10\). In a regression with an intercept and one regressor, the leverage is \(h_{ii}=1/5+x_i^2/10\). The resulting residual adjustments are:
| \(x_i\) | \(e_i\) | \(h_{ii}\) | \(e_i^2/(1-h_{ii})\) |
|---|---|---|---|
| -2 | 1 | 0.6 | \(1/0.4=2.5\) |
| -1 | -1 | 0.3 | \(1/0.7\approx1.429\) |
| 0 | 0 | 0.2 | \(0/0.8=0\) |
| 1 | -1 | 0.3 | \(1/0.7\approx1.429\) |
| 2 | 1 | 0.6 | \(1/0.4=2.5\) |
The high-leverage observations at \(x=-2\) and \(x=2\) receive the largest correction: their squared residuals are multiplied by \(1/0.4=2.5\). The zero residual at \(x=0\) remains zero; HC2 does not add a positive amount to an observed residual square.
From Adjusted Residuals to an HC2 Standard Error
For a simple regression with an intercept, the HC2 variance estimate for the slope can be written in a convenient scalar form. Let \(x_i-\bar{x}\) be the centered regressor and \(S_{xx}=\sum_i(x_i-\bar{x})^2\). The slope’s row of \((X'X)^{-1}X'\) has entries \((x_i-\bar{x})/S_{xx}\), so applying that row on both sides of the HC2 middle matrix gives
Worked Example: Calculating an HC2 Slope Standard Error
Use the five hypothetical observations in the preceding example. There, \(S_{xx}=10\), and the only nonzero residuals occur at \(x=-2,-1,1,2\). Substituting each value into the slope variance formula gives
Therefore the HC2 standard error for the slope is \(\sqrt{0.2286}\approx0.4781\) units of \(y\) per unit of \(x\). For comparison, using the unadjusted HC0 residual squares gives slope variance \([4+1+1+4]/100=0.1000\), and standard error \(\sqrt{0.1000}\approx0.3162\). In this example, the HC2 standard error is larger because the nonzero residuals occur at observations whose leverage corrections are substantial. HC2 need not always produce a larger standard error for every coefficient and data set.
What HC2 Does Under Heteroskedasticity
Now suppose the errors still have conditional mean zero and are conditionally uncorrelated, but their conditional variances differ: \(E(u_i^2\mid X)=\sigma_i^2\). Writing \(\Omega=\operatorname{diag}(\sigma_1^2,\ldots,\sigma_n^2)\), the corresponding residual calculation is
After the HC2 adjustment, this becomes
The weights \(M_{ij}^2/(1-h_{ii})\) are nonnegative and sum to one, because \(\sum_j M_{ij}^2=M_{ii}=1-h_{ii}\). Thus the adjusted squared residual has conditional expectation equal to a weighted average of the error variances, not generally the variance \(\sigma_i^2\) for that same observation. This is why the homoskedastic derivation motivates the HC2 correction but does not establish exact unbiasedness under arbitrary heteroskedasticity.
Worked Example: A Heteroskedasticity Limitation
Return to the design with \(x=(-2,-1,0,1,2)\), and consider observation 1, where \(x_1=-2\) and \(h_{11}=0.6\). For this design the first row of \(H\) is \((0.6,0.4,0.2,0,-0.2)\), so the first row of \(M=I-H\) is \((0.4,-0.4,-0.2,0,0.2)\). Suppose hypothetical errors are conditionally uncorrelated with conditional variances \((4,1,1,1,1)\). Then
The HC2-adjusted squared residual has conditional expectation \(0.88/(1-0.6)=2.20\), whereas the conditional error variance for observation 1 is \(4\). The calculation does not show that HC2 fails as a robust covariance estimator; it shows that its adjustment does not make each adjusted residual square an unbiased estimate of that observation’s own variance. The complete covariance estimator aggregates the adjusted squares with the design vectors, and its use for robust inference relies on appropriate sampling and asymptotic conditions rather than exact finite-sample unbiasedness at every observation.
Practical Interpretation and a Common Pitfall
HC2 matters because leverage is a feature of the design, not merely a large residual. Two observations with identical residuals can contribute differently to the HC2 covariance estimate if their leverages differ. Conversely, a high-leverage observation with a zero residual contributes zero through its own adjusted squared residual. The adjustment targets the residual shrinkage associated with leverage; it does not alter the fitted regression or diagnose why an observation has high leverage.
A common mistake is to say, “The errors have equal variance, so \(E(e_i^2\mid X)=\sigma^2(1-h_{ii})\),” without checking dependence and conditional means. Equal conditional variances alone do not remove covariance terms. The correction is to state the conditions: conditional mean zero, conditionally uncorrelated errors, and common conditional variance. Under those conditions the identity follows from \(M\) being symmetric and idempotent. Under heterogeneous variances, use the weighted-sum expression instead and do not describe HC2 as an exact correction to each \(\sigma_i^2\).
Check Your Understanding
Answer each question using the model and conditions stated in the tutorial.
- Why does the homoskedastic identity for \(E(e_i^2\mid X)\) require conditional uncorrelatedness as well as a common conditional variance?
- An observation has residual \(e_i=-2\) and leverage \(h_{ii}=0.5\). What is its HC2-adjusted squared residual?
- In the simple regression slope formula, why does an observation’s contribution depend on both its leverage and its centered regressor value?
- Under conditionally uncorrelated heteroskedastic errors, what weighted quantity does \(E\{e_i^2/(1-h_{ii})\mid X\}\) estimate?
- Does a larger HC2 standard error than HC0 prove that HC2 must always be larger in every regression? Explain.