Econometrics · Chapter 8

Heteroskedasticity and Robust Standard Errors

Rich households differ far more in how much they save than poor ones do. When the noise around a regression line fans out like that, OLS still aims at the right answer, but the standard errors your software prints can quietly lie. Here you’ll stretch the noise with a slider, then run 2,000 samples and watch the “95%” intervals miss the truth far more than 5% of the time, until robust standard errors put things right. Then you’ll test for the problem and fix it with weights.

The noise

Live numbers

Missions

    What you’re seeing

    The households. Each dot is a simulated household: income across, yearly saving up, both in thousands of dollars. The true rule is saving = −2 + 0.12 × income + u: each extra $1,000 of income adds $120 of saving on average. The gold band shows where 95% of households fall at each income. With “Fan out,” low-income households all save about the same, while high-income households range from big savers to people spending down their savings.

    The ladder. Each run draws a fresh sample, fits OLS, and builds two 95% confidence intervals for the slope: one from the classic standard error that assumes constant noise, and one from the robust (HC1) standard error that doesn’t. A good 95% interval should contain the gold truth line in 95% of samples. Misses show in red.

    The scoreboard. The coverage bars count how often each kind of interval caught the truth. The shaded strip from 94% to 96% is about how much a perfect 95% procedure would wobble over 2,000 tries. The bars on the right show why classic intervals fail: their average standard error is smaller than the real spread of the estimates.

    What heteroskedasticity is

    The word joins the Greek hetero-, “different,” and skedasis, “scattering.” Homoskedasticity, assumption MLR.5 from Chapter 6, says the error has the same variance whatever the regressors are: Var(u | x) = σ². Heteroskedasticity means it doesn’t: Var(u | x) = σ²h(x), with the spread depending on x. Saving against income, spending against income, sales against firm size and test scores against school size all tend to be heteroskedastic.

    OLS is still unbiased. The proof that E(β̂₁) = β₁ used only random sampling and E(u | x) = 0. It never needed a constant variance. So heteroskedasticity doesn’t move the center of the sampling distribution; mission “Still unbiased” checks that.

    But the usual variance formula is wrong. With Var(ui | xi) = σi², the true variance of the slope in simple regression is

    Var(β̂₁) = Σ(xi − x̄)²σi² / SSTx²this equals the textbook σ²/SSTx only when every σi² is the same

    When the noise is biggest where x is far from its mean (fan, bow tie), the classic formula is too small, intervals are too narrow and t statistics too big. When the noise is biggest in the middle (football), it is too large. And OLS is no longer the most precise linear unbiased estimator: the Gauss–Markov theorem needs MLR.5.

    Robust standard errors

    The fix, due to Friedhelm Eicker, Peter Huber and Halbert White, is to estimate each unknown σi² with that observation’s own squared residual ûi²:

    serobust(β̂₁)² = [n/(n − 2)] · Σ(xi − x̄)²ûi² / SSTx²

    One ûi² is a terrible estimate of one σi², but the weighted sum is a good estimate of the sum in large samples. The factor n/(n − k − 1) is the “HC1” small-sample adjustment that Stata’s robust option uses; without it the estimator is called HC0. In multiple regression the same idea gives a whole robust covariance matrix, and robust t and F (Wald) tests.

    Worked example: the same slope, two verdicts on precision

    With 100 households, OLS gives β̂₁ = 0.121, a classic standard error of 0.010 and a robust one of 0.013. With 98 degrees of freedom the 97.5th percentile of t is 1.984.

    • Classic: t = 12.1; 95% interval 0.121 ± 1.984 × 0.010 = [0.101, 0.141].
    • Robust: t = 9.3; 95% interval 0.121 ± 1.984 × 0.013 = [0.095, 0.147].

    Both say saving rises with income. But the classic interval is 23% too narrow, and for a smaller effect that could flip a “significant” result to an insignificant one.

    Small samples. Robust standard errors are a large-sample tool. With 20 or 30 observations under strong heteroskedasticity, HC1 intervals also cover less than 95% (mission “Small samples bite”). James MacKinnon and Halbert White proposed the HC2 and HC3 variants in 1985, which inflate the residuals of high-leverage points; J. Scott Long and Laurie Ervin’s simulations (2000) favored HC3 in samples below about 250. Many applied economists now report robust standard errors by default. For small samples, Angrist and Pischke suggest a rule of thumb: use the larger of the classic and robust standard errors.

    Try this: Choose “Fan out,” push the strength to 1.5 and run 2,000 samples: classic coverage drops to about 87%, robust stays near 94%. Then choose “Football” and run again. Now the classic intervals cover almost 100%: too wide, wasting precision.
    Common mistake: “Heteroskedasticity biases the coefficients, so I need a different estimator”

    It doesn’t. The coefficients are fine; only the standard errors, t statistics, intervals and p-values are off, and robust standard errors fix them in large samples. A second mistake is to think robust standard errors are always larger. They can be smaller, as in the football pattern. And if you see heteroskedasticity, also ask whether the model itself is wrong: a missing log or curve often shows up as a fan in the residuals (Chapter 7).

    Testing for heteroskedasticity, and fixing it with weights

    Breusch–Pagan test. If the error variance moves with the regressors, squared residuals should too. Regress û² on the x’s and use

    LM = n · R²û²  ~  χ²k under homoskedasticity

    (This n·R² form is Roger Koenker’s 1981 version of Trevor Breusch and Adrian Pagan’s 1979 test; an F test that all slopes in that regression are zero works too.) White’s test adds squares and cross products of the regressors; its special form regresses û² on ŷ and ŷ².

    Worked example: a Breusch–Pagan test by hand

    With n = 100, regressing the squared residuals on income gives R² = 0.17. Then LM = 100 × 0.17 = 17.0. The 5% critical value of χ² with 1 degree of freedom is 3.84, so reject constant variance; the p-value is about 0.00004.

    Weighted least squares. If you know the form, Var(u | x) = σ²h(x), divide the whole equation by √h:

    yi/√hi = β₀(1/√hi) + β₁(xi/√hi) + ui/√hi

    The new error has constant variance σ², so OLS on the transformed data, which is WLS, is the best linear unbiased estimator. Each observation gets weight 1/hi: noisy observations count less. This is a case of generalized least squares (GLS), set out by Alexander Aitken in 1935.

    Feasible GLS. Usually h is unknown. Estimate it: regress log(û²) on the regressors (the simulation also adds the square, to catch U-shapes), set ĥ = exp(fitted value), and run WLS with weights 1/ĥ. FGLS is consistent and, in large samples, more efficient than OLS when the variance model is roughly right.

    If the variance model is wrong, WLS and FGLS still estimate β consistently, but their usual standard errors are off. So many people report WLS with robust standard errors too.

    On the current sample

    This uses the sample and settings from the main simulation. Change the noise there and the test and fits update here.

    Goals

      Worked example: weights from a known form

      Suppose Var(u | inc) = σ²·inc, a classic assumption for saving. Then h = inc and the weights are 1/inc. A household earning $50,000 gets three times the weight of one earning $150,000, because its saving is three times less noisy in variance. Equivalently, divide saving, the constant and income by √inc and run OLS without an intercept. Group averages are another common case: if each observation is an average over mi people, its variance is σ²/mi, so weight by group size mi.

      A short history

      Weights. Gauss and Legendre already knew that measurements of unequal accuracy deserve unequal weights. Alexander Aitken gave the general matrix form, generalized least squares, in 1935.

      Robust standard errors. The statisticians Friedhelm Eicker (1967) and Peter Huber (1967) showed how to estimate variances without assuming constant noise. Halbert White brought the idea to econometrics in a 1980 Econometrica paper that also proposed his test; it became one of the most cited papers in economics, and robust standard errors are often called Eicker–Huber–White or “White” standard errors.

      Tests. Trevor Breusch and Adrian Pagan published their test in 1979, and Roger Koenker made it robust to non-normal errors in 1981. In time series, Robert Engle’s ARCH model (1982) let the variance itself follow a pattern over time; he shared the 2003 Nobel memorial prize for it.

      Where it shows up

      Household surveys. Spending, saving and wealth vary more among high earners. Any regression on income should report robust standard errors.

      Firms. Big firms’ sales, profits and investment swing by more dollars than small firms’. Taking logs (Chapter 7) often turns that into roughly constant percent noise.

      Finance. Market volatility comes in calm and stormy spells, so risk measured in calm times can badly understate risk in a crisis. The Long-Term Capital Management case shows how relying on calm-period history can end. Nothing on this page is financial or investment advice.

      Yes-or-no outcomes. When y is 0 or 1, the linear probability model is heteroskedastic by construction: Var(u | x) = p(x)[1 − p(x)]. Chapter 14 takes this up.

      Practice

      1. Warm-up A regression of yearly restaurant spending on income shows residuals that spread out as income rises. Which of these is affected: the OLS slope’s bias, its standard error, or both?

        Show the answer

        Only the standard error (and so t statistics, intervals and p-values). OLS stays unbiased because unbiasedness needs only E(u | x) = 0.

      2. Warm-up β̂₁ = 0.45 with a robust standard error of 0.20 and n = 400. Is it significant at 5%? Give a 95% interval.

        Show the answer

        t = 0.45/0.20 = 2.25 > 1.97, so yes. Interval: 0.45 ± 1.97 × 0.20 = [0.06, 0.84].

      3. Core With n = 250 and three regressors, the R² from regressing û² on the three regressors is 0.031. Carry out the Breusch–Pagan LM test at 5%.

        Show the answer

        LM = 250 × 0.031 = 7.75. The 5% critical value of χ²₃ is 7.81, so we just fail to reject (p ≈ 0.051). Borderline: reporting robust standard errors costs little and is the safe choice.

      4. Core Each observation is the average test score of a school, and schools have between 50 and 2,000 students. If individual scores have constant variance σ², what is the variance of each school’s error, and what weights should WLS use?

        Show the answer

        An average of mi independent scores has variance σ²/mi, so hi = 1/mi and the weight 1/hi = mi, the school’s size. A 2,000-student school counts 40 times as much as a 50-student one.

      5. Core Suppose Var(u | x) = σ²x² in y = β₀ + β₁x + u, with x > 0. Write the transformed equation that WLS estimates by OLS. What happens to the intercept and slope?

        Show the answer

        Divide by x: y/x = β₀(1/x) + β₁ + u/x. The new error has variance σ². In the transformed regression, β₁ is the intercept and β₀ is the slope on 1/x.

      6. Challenge Explain with the formula for Var(β̂₁) why the classic standard error is too small for the fan and bow-tie patterns but too large for the football pattern.

        Show the answer

        The true variance weights each σi² by (xi − x̄)². The classic formula uses the plain average σ̄² instead. If σi² is large exactly where (xi − x̄)² is large (both ends for the bow tie, the far end for the fan), the weighted sum exceeds σ̄²·SSTx, so the classic variance is too small. If σi² is largest near x̄, where the weights are small, the classic variance is too large. In the simulation’s fan at strength 1.5, the real spread is 1.29 times the classic standard error, so a nominal 95% interval covers about 2Φ(1.96/1.29) − 1 = 87%.

      7. Challenge A colleague runs FGLS and finds β̂₁ = 0.118 (se 0.008), against OLS 0.121 (robust se 0.013). She concludes FGLS is better because its standard error is smaller. What else should she check?

        Show the answer

        FGLS standard errors are right only if the variance model is right. She should compare them with robust standard errors for the WLS fit, and check that the OLS and FGLS estimates are close (a big gap can signal misspecification, since both should estimate the same β₁). Here 0.118 and 0.121 are close, and the efficiency gain is plausible, as in the simulation, where FGLS cut the spread by more than half.

      How the interactive works

      The world. Income is uniform between $20,000 and $160,000; saving = −2 + 0.12·income + u (in thousands). The noise u is normal with standard deviation 3·g(z), where z = (income − 90)/70 runs from −1 to 1: exp(γz) for the fan, exp(γ(1.5z² − 0.5)) for the bow tie, and exp(γ(0.5 − 1.5z²)) for the football. γ = 0 is constant noise. The data are simulated with a known truth.

      The estimates. Each run fits OLS and builds 95% intervals as β̂₁ ± t0.975, n−2 × se, with the classic and the HC1 standard error. Weighted least squares uses the true variance function; FGLS regresses log(û²) on z and z², then weights by 1/exp(fitted). The fast slope and standard-error code used in the Monte Carlo is checked against the site’s shared statistics library.

      How it was checked (node tests, 10,000 samples per case, all passed):

      • Slopes, classic and HC1 standard errors matched the shared library to 10⁻¹⁴, and HC1, the Breusch–Pagan statistic and WLS matched NumPy and SciPy to 12 or more digits.
      • Constant noise, n = 100: classic 94.9%, robust 94.5% coverage. Fan at 1.5: classic 86.7%, robust 94.0%. Bow tie at 1.5: 81.4% and 94.0%. Football at 1.5: 99.9% and 95.6%. Fan at 1.5 with n = 20: classic 86.8%, robust 91.0%.
      • With n = 500 the real spread was 1.287 times the average classic standard error, matching the formula’s 1.287 for this design.
      • The mean slope stayed within four standard errors of 0.12 in every case. The Breusch–Pagan test rejected 4.5% of the time at the 5% level under constant noise. Under the fan (1.5, n = 100), the spread of the estimates was 0.0175 for OLS, 0.0076 for WLS and 0.0080 for FGLS.

      Check yourself

      1. Under heteroskedasticity, the OLS slope is…

        Show the answer

        Unbiasedness needs only random sampling and E(u | x) = 0.

      2. Classic 95% intervals covered the truth in 87% of 2,000 samples. Why?

        Show the answer

        Too-small standard errors make intervals too narrow. 87% is far outside the 94–96% wobble expected from 2,000 tries.

      3. Robust (HC1) standard errors work well…

        Show the answer

        They need no model of the variance, but they rely on large-sample approximations; in very small samples they can still be too small.

      4. The Breusch–Pagan test regresses…

        Show the answer

        LM = n·R² from regressing û² on the x’s. (Plain residuals are uncorrelated with the regressors by construction.)

      5. If Var(u | x) = σ²·x, WLS gives each observation a weight of…

        Show the answer

        Weights are 1/h(x) = 1/x, which is the same as dividing each variable by √x.

      Sources

      • J. M. Wooldridge, Introductory Econometrics: A Modern Approach, 7th ed. (Cengage, 2020), Chapter 8 (Heteroskedasticity): consequences for OLS, robust inference, the Breusch–Pagan and White tests, weighted least squares and feasible GLS.
      • J. H. Stock and M. W. Watson, Introduction to Econometrics, 4th ed. (Pearson, 2019), Section 5.4 (Heteroskedasticity and Homoskedasticity).
      • J. D. Angrist and J.-S. Pischke, Mostly Harmless Econometrics (Princeton University Press, 2009), Section 8.1 (the bias of robust standard errors).
      • Penn State STAT 501, Lesson 13: Weighted Least Squares.
      • H. White, “A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity,” Econometrica 48(4), 1980, 817–838.
      • T. S. Breusch and A. R. Pagan, “A Simple Test for Heteroscedasticity and Random Coefficient Variation,” Econometrica 47(5), 1979, 1287–1294. R. Koenker, “A Note on Studentizing a Test for Heteroscedasticity,” Journal of Econometrics 17, 1981, 107–112.
      • J. G. MacKinnon and H. White, “Some Heteroskedasticity-Consistent Covariance Matrix Estimators with Improved Finite Sample Properties,” Journal of Econometrics 29, 1985, 305–325. J. S. Long and L. H. Ervin, “Using Heteroscedasticity Consistent Standard Errors in the Linear Regression Model,” The American Statistician 54(3), 2000, 217–224.
      Saved on this device only.
      @teddyrookbook GitHub