Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
Robust standard errors fix how uncertainty is calculated around a regression coefficient — they do not fix the coefficient itself, and they do not fix a wrong model. When a regression’s error variance isn’t constant across observations (heteroscedasticity), ordinary least squares (OLS) coefficients typically stay unbiased, but the conventional formula for their standard errors is built on a constant-variance assumption and gives the wrong answer once that assumption fails. Heteroscedasticity-consistent (HC) standard errors — also called robust standard errors or the White sandwich estimator — recompute that uncertainty using an estimator that doesn’t require constant variance. Four variants are in common use, labeled HC0 through HC3, and they don’t all give the same answer. This guide works through what each variant actually does differently, why HC3 is the usual recommendation in small samples, and the more consequential distinction: telling apart genuine heteroscedasticity from a misspecified functional form that happens to produce heteroscedastic-looking residuals — because robust standard errors correct only the first problem, and silently leave the second one in place.
What Robust Standard Errors Actually Fix — and What They Don’t
Halbert White’s 1980 Econometrica paper (“A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity,” Econometrica 48(4), 817–838) introduced the original heteroscedasticity-consistent covariance matrix estimator, now called HC0. The logic: OLS’s usual standard-error formula assumes a single scalar error variance (the homoscedasticity assumption in the Gauss-Markov theorem; see What Is Homoscedasticity?) shared by every observation. White’s estimator instead uses each observation’s own squared residual as a stand-in for its individual variance, producing standard errors that stay valid (asymptotically) whether or not that constant-variance assumption holds.
It’s worth being precise about the scope of the fix:
- The coefficients don’t change. Robust standard errors are computed from the same OLS point estimates. If the fitted model is correctly specified, those estimates were already unbiased and consistent under heteroscedasticity — heteroscedasticity is a statement about the spread of the errors, not their mean, so it doesn’t move the coefficients.
- Only the standard errors, t-statistics, confidence intervals, and p-values change. That’s the entire scope of the correction — which is also exactly why it’s such a popular default: no change to the model specification, no need to identify or model the source of the heteroscedasticity, just a different formula applied to the same fitted residuals.
- They assume the mean function is right. Every HC variant is a fix for the variance formula, built on top of whatever functional form you already fit. If that functional form is wrong — a missing quadratic term, an omitted interaction, the wrong link function — robust standard errors report a more honest uncertainty estimate around a coefficient that is still measuring the wrong thing. See the misspecification section below; this is the failure mode most tutorials skip.
For the formal diagnostic step — testing whether heteroscedasticity is actually present before reaching for a fix — see Breusch-Pagan Test for Heteroscedasticity, which covers the Breusch-Pagan and White’s tests and the residual-plot check that should come first.
The Four Variants: HC0, HC1, HC2, HC3
All four are “sandwich” estimators of the same general form — the coefficient covariance matrix is (X′X)-1 (X′ Ω X) (X′X)-1, where Ω is a diagonal matrix built from the squared residuals. They differ only in how each observation’s squared residual is weighted before it goes into Ω. James MacKinnon and Halbert White’s 1985 follow-up paper (“Some Heteroskedasticity-Consistent Covariance Matrix Estimators with Improved Finite Sample Properties,” Journal of Econometrics 29(3), 305–325) introduced HC1 through HC3 specifically because HC0, while asymptotically valid, tends to understate standard errors in finite samples.
| Variant | Per-observation weight | What it corrects for | Typical default |
|---|---|---|---|
| HC0 | ei2 (the raw squared residual) | Nothing beyond White’s original asymptotic correction — no finite-sample adjustment | SAS PROC REG (the HCCMETHOD= default is 0) |
| HC1 | ei2 × n/(n−k) | A degrees-of-freedom correction, the same n/(n−k) factor used elsewhere in OLS | Stata’s robust option; the default cov_type in statsmodels’ get_robustcov_results |
| HC2 | ei2 / (1−hii) | Leverage — high-leverage points get their squared residual scaled up, since OLS residuals at high-leverage points are systematically too small | Not the default in R, Stata, statsmodels or SAS; available in all four |
| HC3 | ei2 / (1−hii)2 | Leverage, more aggressively — approximates a jackknife (leave-one-out) estimator | The default type in R’s sandwich::vcovHC; available via vce(hc3) in Stata |
hii is the “hat value” or leverage of observation i — how far its predictor values sit from the center of the data, on a 0–1 scale. A point with high leverage pulls the regression line toward itself, which mechanically shrinks its own residual; HC2 and HC3 correct for that by inflating the residual back up before it’s used to estimate variance, with HC3’s squared denominator applying a stronger correction than HC2’s.
Why HC3 Is Usually Preferred in Small Samples
Long and Ervin’s 2000 paper (“Using Heteroscedasticity Consistent Standard Errors in the Linear Regression Model,” The American Statistician 54(3), 217–224) is the paper most often cited for the HC3 recommendation: across their simulations, HC3 came closest to the nominal test size and had the best power, particularly in small samples, while HC0 and HC1 tended to produce standard errors that were too small — and therefore confidence intervals that undercovered and p-values that ran too low — when the sample was small or contained high-leverage points.
The mechanism is the leverage correction described above. In a small sample, a handful of high-leverage observations can dominate the squared-residual sum that every HC estimator is built from, and HC0/HC1 don’t adjust for that at all (HC1 only corrects the overall degrees of freedom, not any individual observation’s leverage). HC3’s per-observation (1−hii)2 weighting specifically counteracts the tendency of high-leverage points to look artificially well-fit, which is exactly the situation where HC0/HC1 standard errors are most likely to be too small. As the sample grows, hii shrinks toward 1/n for every point and the four variants converge — the choice matters most exactly where robust standard errors are otherwise least reliable: small n.
A reproducible check: coverage of a 95% interval at n=20
To see the practical size of the difference, a Monte Carlo simulation with 2,000 replications of a simple regression with n=20 and a genuinely heteroscedastic error (standard deviation growing linearly with the predictor), true slope fixed at 1.5, then checked how often a nominal 95% confidence interval — built from each SE type using the standard z=1.96 critical value — actually contained the true slope.
- Conventional (homoscedastic) SE: 91.20% coverage
- HC0: 88.70% coverage
- HC1: 90.35% coverage
- HC2: 90.85% coverage
- HC3: 92.55% coverage
Two things worth noticing. First, HC3 came closest to the nominal 95% target, consistent with the Long and Ervin finding above. Second — and this is a genuinely useful corrective to the “robust is always safer” intuition — HC0 actually undercovered more than doing nothing (the conventional SE), because at n=20 the finite-sample understatement in HC0 outweighs the benefit of relaxing the constant-variance assumption. Reaching for HC0 reflexively in a small sample isn’t automatically an improvement; the finite-sample correction in HC1–HC3 is doing real work here, not just cosmetic rounding.
Worked Example: How Much Do the Variants Actually Differ on One Dataset?
On a single fitted regression (n=200, predictor x from 1 to 50, error standard deviation growing with x2 — a deliberately severe case), the five standard-error estimates for the slope came out as:
- Conventional: 0.8288
- HC0: 1.0634
- HC1: 1.0688
- HC2: 1.0720
- HC3: 1.0806
Here the conventional standard error understates the true uncertainty by roughly 30% relative to HC3 — a t-statistic computed on the conventional SE would overstate significance. But the intercept moved the opposite direction (conventional SE 24.20 versus 17.0–17.2 for the HC variants) — the conventional formula overstated uncertainty there. This is a useful reminder that heteroscedasticity doesn’t push every coefficient’s standard error the same direction; which coefficients get understated versus overstated depends on how the error variance pattern lines up with each variable’s own distribution, not on a fixed rule of thumb. Don’t assume “robust SEs will always come out bigger” — check the specific case.
When Robust SEs Fix a Real Problem — and When They Mask a Misspecified Model
This is the distinction most treatments of robust standard errors skip, and it’s the one that actually changes what you should do next. A residual plot that fans out, or a significant Breusch-Pagan/White’s test, has more than one possible cause:
- Genuine heteroscedasticity with a correctly specified mean function. The relationship between predictors and the expected outcome is right; only the error spread varies with the predictors (measurement error that scales with the outcome’s magnitude is a common real-world source). Robust standard errors are the right tool here — they leave a correctly specified model’s coefficients alone and fix the inference around them.
- A misspecified functional form that produces heteroscedastic-looking residuals as a side effect. An omitted quadratic term, a missing interaction, or the wrong link function can all make squared residuals correlate with a predictor even when the true error variance is constant — because the residuals aren’t just noise anymore, they’re partly the unmodeled curvature. In this case the coefficient itself is biased (it’s estimating an average effect across a relationship that isn’t actually linear), and no standard-error correction touches that. Robust SEs will faithfully report a more honest — but still wrong — interval around a biased number.
An illustration: data simulated from a true quadratic relationship (y = 1 + 0.4x + 0.15x2 + e, homoscedastic error, n=50), then deliberately fit a misspecified linear-only model. The linear-only fit reported a single slope of 0.3389 for every value of x — but the true relationship’s local slope is 0.40 at x=0 and 1.60 at x=4; the linear model isn’t a noisy estimate of one true effect, it’s averaging over an effect that genuinely changes size across the range of x. Its squared residuals correlated with x at r=0.10 in this run — a real, detectable pattern, and one a Breusch-Pagan test can pick up as if it were classic heteroscedasticity. Switching that model to HC3 standard errors (0.2514 for the intercept, 0.1001 for the slope, versus conventional 0.2444 and 0.0830) makes the interval around 0.3389 more honest about sampling noise — but 0.3389 was never a meaningful single number to attach an interval to, since the true effect isn’t constant across x. The fix here is not a robust standard error; it’s adding the quadratic term back into the model.
Before defaulting to robust standard errors, check the functional form first: plot residuals against each predictor and against fitted values and look for curvature, not just fanning; try an added quadratic or interaction term where theory allows one; check whether a link-function or transformation issue (see censoring vs. truncation for one specific case where the wrong model class produces a similar-looking symptom) explains the pattern before concluding the mean function is fine and only the variance needs correcting. Robust standard errors are the right response to “the model is right but the variance formula is wrong” — they are not a general-purpose patch for “the residual plot looks bad.” See Multicollinearity and VIF in Regression and Endogeneity: The Three Sources, and the Remedy That Matches Each for the other two regression-assumption violations worth ruling out in the same pass, since all three can produce overlapping symptoms in a residual plot.
Which Variant Each Package Uses by Default
The same data can give different robust standard errors in different software, because the packages do not share a default. R’s sandwich::vcovHC uses type = "HC3" unless told otherwise. Stata’s vce(robust) is HC1, and vce(hc2) and vce(hc3) are separate options. In Python’s statsmodels, get_robustcov_results defaults to cov_type="HC1". SAS PROC REG’s HCCMETHOD= option takes 0, 1, 2 or 3, and 0 (HC0) is its default. The data table below the guide lays out the weighting formula and option name for each variant in each package, so you can match a specification across tools.
Why Stata, R and statsmodels can disagree on identical data
- Different default variant. A plain “robust” call is HC1 in Stata and HC3 in R’s
vcovHC; HC3 weights each squared residual by 1/(1−hii)2 while HC1 applies only n/(n−k). With high-leverage points the two can differ visibly; with a large n they converge. - Different reference distribution. In statsmodels,
use_tis left unset for robust covariance types and resolves to false, so p-values and intervals use the normal (z) distribution. Stata’sregressreports t-based statistics. The standard errors can match exactly while the p-values differ slightly in small samples. Setuse_t=Truein statsmodels if you want t-based inference. - Same HC1 arithmetic. Stata’s n/(n−k) and statsmodels’ n/df_resid are the same factor for a full-rank design matrix, so an HC1 comparison between the two should agree on standard errors.
Always report which variant and which reference distribution you used, not just “robust standard errors”.
How Large Does n Need to Be? The 250 Rule and Observations per Regressor
The SAS/STAT documentation for PROC REG cites Long and Ervin’s recommendation to use HC3 when the sample has fewer than 250 observations. That is a rule of thumb from simulation results, not a threshold with a theoretical derivation, and it is not the only thing that matters. The Stata Blog’s practical discussion of robust standard errors stresses that performance depends on the ratio of observations to regressors (n/k), not on n alone, because the average leverage in a regression is k/n: with many regressors relative to the sample, every observation has high leverage and the leverage corrections in HC2 and HC3 do more work.
The Stata Blog illustrates this with a simulation at N=100: at a nominal 5% test size, HC1 rejected a true null between 15.9% and 25.5% of the time depending on the design, while HC3 rejected between 8.6% and 9.6% of the time. At N=5,000 all the variants were close to the nominal 5%. HC3 was closer to nominal in the small sample, though still not exactly 5%, and the gap between variants disappeared as n grew.
Limits of HC3 and the Leverage-Oriented Variants
- HC3 is not always better than HC1. The Stata Blog notes there is no silver bullet: with discrete (for example binary) covariates and strong heteroscedasticity at small N, HC3 can be too conservative, producing standard errors that are larger than needed and tests that reject too rarely.
- Leverage near 1 causes trouble for any of them. The HC2 and HC3 weights divide by 1−hii, so an observation with leverage close to 1 receives an extreme weight. Check the hat values before relying on any variant.
- HC4, HC4m and HC5 exist. R’s
sandwich::vcovHCdocumentstypevalues"const","HC0"through"HC5"and"HC4m"; HC4 and HC5 are the variants aimed at samples with high-leverage points. If your diagnostics show a few extreme leverage values, these are the options to look at in R.
Choosing a Variant: A Short Checklist
- Confirm the mean function first (see the misspecification section above); no HC variant repairs a wrong model.
- Compute n, k and the hat values. If n is below about 250, or n/k is small, or a few observations have large leverage, prefer HC3 (or investigate HC4/HC5 in R).
- If n is large and leverage is unremarkable, HC1, HC2 and HC3 should agree closely; report your software’s default and say which it is.
- If your observations are clustered, use a cluster-robust estimator instead of HC0–HC3.
- Write down the package, the variant and the reference distribution (z or t) in the methods section.
Computing Robust Standard Errors in R, Stata, and Python
- R: fit the model normally with
lm(), thensandwich::vcovHC(model, type = "HC3")for the covariance matrix, wrapped inlmtest::coeftest(model, vcov = sandwich::vcovHC(model, type = "HC3"))for a full coefficient table with the corrected standard errors, t-values, and p-values. Swaptypefor"HC0"/"HC1"/"HC2"to use a different variant. - Stata:
regress y x, vce(robust)uses HC1 (more on the command in Regression in Stata); the Stata Blog describes this as the n/(n−k) adjustment. For HC3 specifically, useregress y x, vce(hc3)(available in current Stata releases). - Python: with
statsmodels,sm.OLS(y, X).fit(cov_type = "HC3")refits the covariance matrix with the chosen HC variant;cov_typeaccepts"HC0","HC1","HC2", or"HC3"directly.
All three approaches use the same fitted coefficients as the original OLS model — only the reported standard errors, confidence intervals, and p-values change, which is the whole point: nothing about how the model was fit needs to change to apply a robust covariance estimator after the fact.
Frequently Asked Questions
Do robust standard errors change the regression coefficients?
No. They’re computed from the same fitted OLS coefficients; only the standard errors, t-statistics, confidence intervals, and p-values change.
Which HC variant should I use by default?
HC3 is the most commonly recommended default, particularly for small-to-moderate samples or when high-leverage observations are present, per Long and Ervin (2000). HC1 remains the most common software default (it’s what Stata’s plain robust option uses), which is why results computed in different software can look slightly different even on identical data.
Can I use robust standard errors with clustered or panel data?
HC0–HC3 assume independent observations. If your data are clustered (repeated measures on the same subject, students within schools), use a cluster-robust variance estimator instead — a different adjustment built for correlation within clusters rather than heteroscedasticity across independent units. See Generalized Estimating Equations (GEE) for one structured way to handle within-cluster correlation directly in the model rather than only in the standard errors.
Does a significant Breusch-Pagan test mean I need robust standard errors?
Not automatically. It means the squared residuals correlate with your predictors, which can come from genuine heteroscedasticity or from a misspecified functional form (see the section above). Check the functional form before concluding the fix is purely a standard-error correction.
Why do Stata and R give different robust standard errors?
Their defaults differ. Stata’s vce(robust) is HC1, while R’s sandwich::vcovHC defaults to HC3. Specify the same variant in both (vce(hc3) in Stata, type = "HC3" in R) and the standard errors should agree.
What is the default type in vcovHC?
HC3. The sandwich package’s vcovHC uses type = "HC3" when you do not specify one.
Is HC3 always better than HC1?
No. HC3 usually has better small-sample behaviour, but the Stata Blog notes it can be too conservative with discrete covariates and strong heteroscedasticity at small N. The ratio of observations to regressors and the leverage values matter as well as n.
What sample size should I use HC3 for?
A common rule of thumb, from Long and Ervin and quoted in the SAS/STAT PROC REG documentation, is to use HC3 when n is below 250. Above that the variants tend to converge, provided n/k is not small and leverage is not extreme.
Why do statsmodels p-values differ from Stata’s with the same standard errors?
statsmodels uses the normal distribution for robust covariance types unless you set use_t=True; Stata’s regress reports t-based p-values.
Reproducibility Note
The simulated figures in this guide use fixed parameters. Coverage check: n=20, 2,000 replications, true slope 1.5, error standard deviation proportional to the predictor, nominal 95% intervals with z=1.96, standard errors HC0–HC3 as defined above. Misspecification example: n=50, y = 1 + 0.4x + 0.15x2 + e with homoscedastic error, fitted with a linear-only model. Figures from other studies are attributed to the sources listed below.
Sources
- vcovHC reference, sandwich R package: default type HC3; types const, HC0–HC5.
- statsmodels linear_model source: HC0–HC3 weights.
- statsmodels get_robustcov_results documentation: default cov_type HC1; use_t.
- SAS/STAT PROC REG: heteroscedasticity-consistent covariance matrix estimators: HCCMETHOD, HC3 for n<250.
- Stata Blog: Heteroskedasticity robust standard errors, some practical considerations: vce(robust) as HC1, vce(hc2), vce(hc3), n/k and simulation results.
- White (1980), Econometrica 48(4); MacKinnon and White (1985), Journal of Econometrics 29(3); Long and Ervin (2000), The American Statistician 54(3).
Data: HC0-HC3 heteroskedasticity-consistent covariance estimators: weighting formula and software defaults across R, Stata, statsmodels and SAS
Compares the four White/MacKinnon-White sandwich variants by the per-observation squared-residual weight used, the option name in each of four statistical packages, and which variant each package uses when the user asks for plain robust errors. Compiled from the sandwich (R) reference page, the statsmodels documentation and source, the SAS/STAT PROC REG documentation and the Stata blog on robust standard errors.
Period covered: 2026.
| Variant | Per-observation weight on squared residual e_i^2 | R sandwich::vcovHC type | Stata regress option | statsmodels cov_type | SAS PROC REG HCCMETHOD | Software where it is the default |
|---|---|---|---|---|---|---|
| HC0 | 1 (no adjustment) | HC0 | n/a | HC0 | 0 | SAS PROC REG (HCCMETHOD default) |
| HC1 | n/(n-k) | HC1 | vce(robust) | HC1 | 1 | Stata regress vce(robust); statsmodels get_robustcov_results cov_type default |
| HC2 | 1/(1-h_ii) | HC2 | vce(hc2) | HC2 | 2 | none of the four |
| HC3 | 1/(1-h_ii)^2 | HC3 | vce(hc3) | HC3 | 3 | R sandwich::vcovHC (type default) |
Sources
- vcovHC reference, sandwich R package (accessed 2026-11-14)
- statsmodels linear_model source (cov_HC0 to cov_HC3) (accessed 2026-11-14)
- statsmodels get_robustcov_results documentation (accessed 2026-11-14)
- SAS/STAT PROC REG: heteroscedasticity-consistent covariance matrix estimators (accessed 2026-11-14)
- Stata Blog: Heteroskedasticity robust standard errors, some practical considerations (accessed 2026-11-14)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







