Tutorials › Econometrics (Graduate) › Leverage Corrections in HC2

Heteroskedasticity-Robust Inference · Tutorial 112 of 952

Leverage Corrections in HC2

Learn how HC2 uses regression leverage to adjust squared residuals and how that adjustment changes robust standard errors.

Intermediate 10 min read

What You'll Learn

  • Define the HC2 covariance estimator and its leverage adjustment
  • Derive the expected squared OLS residual under conditionally uncorrelated errors
  • Explain why leverage shrinks residuals under homoskedasticity
  • Calculate HC2-adjusted residual squares for observations with different leverage
  • Compute an HC2 standard error and distinguish it from HC0
  • Recognize why HC2 is not an exact variance correction under heteroskedasticity

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\).

Definition: The HC2 covariance estimator for the OLS coefficient vector is $$ \widehat{\operatorname{Var}}_{\mathrm{HC2}}(\hat{\beta}) =(X'X)^{-1}X' \operatorname{diag}\!\left(\frac{e_i^2}{1-h_{ii}}\right) X(X'X)^{-1}. $$ Here \(\operatorname{diag}(a_i)\) denotes a diagonal matrix whose \(i\)th diagonal entry is \(a_i\). The HC2 standard error for a coefficient is the square root of the corresponding diagonal entry of this estimated covariance matrix.

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

$$ E(e_i^2\mid X) = \sigma^2\sum_{j=1}^n M_{ij}^2 = \sigma^2 M_{ii} = \sigma^2(1-h_{ii}). $$

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})\)
-210.6\(1/0.4=2.5\)
-1-10.3\(1/0.7\approx1.429\)
000.2\(0/0.8=0\)
1-10.3\(1/0.7\approx1.429\)
210.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

$$ \widehat{\operatorname{Var}}_{\mathrm{HC2}}(\hat{\beta}_1) =\frac{1}{S_{xx}^2} \sum_{i=1}^n \frac{(x_i-\bar{x})^2e_i^2}{1-h_{ii}}. $$

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

$$ \begin{aligned} \widehat{\operatorname{Var}}_{\mathrm{HC2}}(\hat{\beta}_1) &=\frac{1}{10^2}\left[ \frac{4(1)}{0.4} +\frac{1(1)}{0.7} +\frac{1(1)}{0.7} +\frac{4(1)}{0.4} \right]\\ &=\frac{10+1.4286+1.4286+10}{100}\\ &\approx 0.2286. \end{aligned} $$

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

$$ E(e_i^2\mid X) =\sum_{j=1}^n M_{ij}^2\sigma_j^2. $$

After the HC2 adjustment, this becomes

$$ E\!\left(\frac{e_i^2}{1-h_{ii}}\middle|X\right) =\sum_{j=1}^n \frac{M_{ij}^2}{1-h_{ii}}\sigma_j^2. $$

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

$$ \begin{aligned} E(e_1^2\mid X) &=(0.4)^2(4)+(-0.4)^2(1)+(-0.2)^2(1)+(0)^2(1)+(0.2)^2(1)\\ &=0.64+0.16+0.04+0+0.04=0.88. \end{aligned} $$

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\).

Key takeaway: HC2 replaces \(e_i^2\) with \(e_i^2/(1-h_{ii})\) in the robust covariance estimator. Under conditionally uncorrelated homoskedastic errors, this adjustment exactly removes the leverage factor in the expected squared residual. Under heteroskedasticity, it is a leverage-based correction, not a guarantee of exact observation-level variance recovery.

Check Your Understanding

Answer each question using the model and conditions stated in the tutorial.

  1. Why does the homoskedastic identity for \(E(e_i^2\mid X)\) require conditional uncorrelatedness as well as a common conditional variance?
  2. An observation has residual \(e_i=-2\) and leverage \(h_{ii}=0.5\). What is its HC2-adjusted squared residual?
  3. In the simple regression slope formula, why does an observation’s contribution depend on both its leverage and its centered regressor value?
  4. Under conditionally uncorrelated heteroskedastic errors, what weighted quantity does \(E\{e_i^2/(1-h_{ii})\mid X\}\) estimate?
  5. Does a larger HC2 standard error than HC0 prove that HC2 must always be larger in every regression? Explain.
Clinical Biostats