Step 11: Heteroskedasticity
- Heteroskedasticity means the variance of the error changes with the explanatory variables: \( \text{Var}(u \mid x) \) is not a constant. In cross-section data it is the normal case, not the exception.
- OLS coefficients stay unbiased and consistent. What breaks is the usual standard error, and with it every \( t \) statistic, \( p \)-value, confidence interval and \( F \) test. OLS is also no longer BLUE.
- Detect it with residual plots, the Breusch–Pagan test (\( LM = nR^2 \) from regressing \( \hat{u}^2 \) on the \( x \) variables) and the White test (which adds squares and cross products).
- Fix inference with heteroskedasticity-robust standard errors (HC1 in large samples, HC3 in small ones). If you know the shape of the variance, weighted least squares is more efficient.
- Exam point: a test that fails to reject is not proof of homoskedasticity. Report robust standard errors anyway.
What heteroskedasticity is
Back in Step 6, OLS was the best linear unbiased estimator under five assumptions. The fifth, MLR.5, was homoskedasticity: the error has the same variance whatever the values of the explanatory variables.
Because the error has mean zero, its variance is just its average squared value: \( \text{Var}(u \mid \mathbf{x}) = E(u^2 \mid \mathbf{x}) \). So heteroskedasticity is about the typical size of the error, ignoring its sign. It says nothing about the error’s average, which is still zero.
Why it is so common in cross-sections
Heteroskedasticity appears whenever the room for unexplained variation grows or shrinks with an explanatory variable.
- Income and spending. A household on $20,000 a year spends most of it on necessities; one on $200,000 can save a lot or spend a lot.
- Firm size. An error of 10% of predicted sales is a few thousand dollars for a small firm and millions for a large one.
- Wages and education. More schooling opens a wider range of jobs and pay.
- Group averages. An average over \( m_i \) people has error variance \( \sigma^2/m_i \): bigger groups are less noisy.
This step uses the companion wage data from Econometrics Made Simple, Chapter 11. They were simulated with heteroskedasticity built in: the standard deviation of the error in the log-wage equation is \( 0.30 + 0.012\,\text{educ} \), rising from about 0.40 at 8 years of schooling to about 0.52 at 18 years. You know the right answer, which makes the data ideal for checking whether each tool finds it.
What heteroskedasticity does to OLS
Look again at the proof that OLS is unbiased (Step 4). It used linearity, random sampling, variation in \( x \) and the zero conditional mean assumption. Homoskedasticity never appeared. So the coefficients are fine. The problem is their variance.
In simple regression the OLS slope is the true slope plus a weighted sum of the errors, \( \hat\beta_1 = \beta_1 + \sum (x_i-\bar{x})u_i / \text{SST}_x \). The errors are independent, so the variance of the sum is the sum of the variances, and each term has variance \( (x_i-\bar{x})^2\sigma_i^2 \):
Only when every \( \sigma_i^2 \) equals the same \( \sigma^2 \) can you take it outside the sum and get the familiar \( \sigma^2/\text{SST}_x \). Under heteroskedasticity the familiar formula is simply the wrong formula. Notice the weights: each \( \sigma_i^2 \) is multiplied by \( (x_i-\bar{x})^2 \). If the noisiest observations sit far from \( \bar{x} \), which is typical when the variance rises with \( x \), the usual standard error is too small. If they sit near the middle, it is too large.
Five observations have \( x = 1, 2, 3, 4, 5 \) and error variances \( \sigma_i^2 = \sigma^2 x_i^2 \). Compare the true variance of the OLS slope with what the usual formula reports.
The usual formula understates the variance by about 11%, because the biggest error variances sit at the extreme \( x \) values, which have the most influence on the slope. Move the large variance to \( x = 3 \) instead and the usual formula overstates the truth: the direction depends on where the noise sits.
| Property of OLS | Still holds? | Comment |
|---|---|---|
| Unbiased and consistent | Yes | needs only MLR.1–MLR.4 |
| \( R^2 \) meaningful | Yes | built from unconditional variances |
| Usual standard errors | No | biased, and not even consistent; fix with robust standard errors |
| Usual \( t \), \( F \) and LM tests | No | do not have their stated distributions, even in large samples |
| BLUE (Gauss–Markov) | No | weighted least squares is more efficient |
Spotting it: residual plots
The errors are unobserved, but the OLS residuals \( \hat{u}_i \) estimate them. Since \( \text{Var}(u \mid \mathbf{x}) = E(u^2 \mid \mathbf{x}) \), the natural check is whether \( \hat{u}_i^2 \) rises or falls as a suspect variable, or the fitted value \( \hat{y}_i \), changes. Two plots are standard: residuals against a suspect \( x \), and residuals against the fitted values.
The running example is the log-wage equation from Econometrics Made Simple, Chapter 11, estimated on 1,000 workers:
where \( \text{expersq} = \text{exper}^2/100 \). Figure 1 averages the squared residuals at each level of schooling.
The pattern is gentle but clear. The average squared residual is about 0.14 for workers with 8 or 9 years of school and about 0.23 for those with 14 or more. A regression of \( \hat{u}^2 \) on education has a slope of 0.0134 with a \( t \) statistic of 2.86. That is the pattern the data were built with.
The book’s house-price data (500 sales) show a stronger case. With price in dollars the residuals fan out: their standard deviation is about $43,000 for houses predicted below $250,000 and about $115,000 above $550,000. With log price, the band has roughly the same width everywhere, because a log model makes errors proportional. Taking logs (Step 8) is often the simplest cure; there the BP test passes easily (\( p = 0.744 \)).
The Breusch–Pagan test
The null hypothesis is homoskedasticity, \( H_0: E(u^2 \mid x_1, \dots, x_k) = \sigma^2 \). Under the alternative, suppose \( u^2 \) is linearly related to the \( x \) variables, \( u^2 = \delta_0 + \delta_1 x_1 + \dots + \delta_k x_k + v \). Homoskedasticity is then the joint null \( \delta_1 = \dots = \delta_k = 0 \). Replace the unobserved \( u^2 \) with \( \hat{u}^2 \) and you have the Breusch–Pagan (BP) test. The version below, which does not need normal errors, is due to Koenker (1981).
| Step | What you do |
|---|---|
| 1 | Estimate the model by OLS and save the squared residuals \( \hat{u}_i^2 \). |
| 2 | Regress \( \hat{u}^2 \) on \( x_1, \dots, x_k \) with an intercept. Record its \( R^2 \), called \( R^2_{\hat{u}^2} \). |
| 3 | Compute \( LM = nR^2_{\hat{u}^2} \) and compare it with the \( \chi^2_k \) critical value (or use the \( F \) version, which every package prints for the auxiliary regression). |
| 4 | Reject homoskedasticity if the statistic exceeds the critical value. |
Run the BP test on the log-wage equation (\( n = 1{,}000 \), \( k = 5 \)). The auxiliary regression of \( \hat{u}^2 \) on all five regressors has \( R^2 = 0.01056 \). A second, targeted version regresses \( \hat{u}^2 \) on education alone. What do the two tests say at 5%?
The targeted test finds what the data were built with. The general lesson: tests are most powerful when economic reasoning or a plot tells you where to look.
The White test
The BP test looks only for variance that is linear in the \( x \) variables. White (1980) showed that the usual standard errors are valid as long as \( u^2 \) is uncorrelated with the \( x_j \), their squares and their cross products. The White test adds all those terms to the auxiliary regression and tests them jointly with \( LM = nR^2 \). It catches curved patterns that BP misses, but the number of terms grows fast: with \( k \) regressors there are \( k(k+3)/2 \) of them, 20 for \( k = 5 \).
A shortcut keeps the spirit with only two terms. The fitted value \( \hat{y} \) combines all the \( x \) variables, and \( \hat{y}^2 \) combines all their squares and cross products. So regress \( \hat{u}^2 \) on \( \hat{y} \) and \( \hat{y}^2 \) and test both slopes: \( LM = nR^2 \sim \chi^2_2 \) whatever the number of regressors. This is the special White test.
| Test on the log-wage equation (auxiliary regressors) | LM | df | \( p \)-value |
|---|---|---|---|
| Breusch–Pagan (all five \( x \) variables) | 10.56 | 5 | 0.061 |
| Breusch–Pagan (educ only) | 8.11 | 1 | 0.004 |
| White, full (levels, squares, cross products) | 29.34 | 18 | 0.044 |
| White, special (\( \hat{y} \), \( \hat{y}^2 \)) | 5.38 | 2 | 0.068 |
The full White test has 18 terms, not 20, because two repeat earlier ones: \( \text{female}^2 = \text{female} \) for a dummy, and \( \text{exper}^2 = 100 \times \text{expersq} \). The tests disagree at 5% because the heteroskedasticity in log wages is mild. The one aimed at the right variable is the most powerful. (Results from Econometrics Made Simple, Chapter 11.)
Heteroskedasticity-robust standard errors
Testing tells you whether there is a problem. The standard fix does not change the estimates at all. It replaces the wrong variance formula with one that is valid whether or not the errors are heteroskedastic. The trick, due to Eicker, Huber and White, is to put the squared residual \( \hat{u}_i^2 \) in place of each unknown \( \sigma_i^2 \):
One squared residual is a poor estimate of one \( \sigma_i^2 \). But the formula needs only a weighted average of them, and averages of many noisy terms are accurate. In large samples it is consistent under heteroskedasticity of any form, and under homoskedasticity too. Its square root is the robust (White, or sandwich) standard error. In multiple regression the same idea applies to each coefficient, and software does the matrix algebra.
HC0, HC1, HC2 and HC3
HC0 tends to be too small in small samples, because OLS residuals are on average smaller than the errors: the line is chosen to make them small. MacKinnon and White (1985) proposed three adjustments, each replacing \( \hat{u}_i^2 \) by something larger.
Here \( h_{ii} \) is the leverage of observation \( i \): how unusual its \( x \) values are. HC1 is Stata’s robust option and the most common choice in published economics. HC2 and HC3 inflate the residuals of high-leverage points most, because the fitted line is pulled towards them; HC3 is the default in R’s sandwich package.
Five observations are \( (x, y) = (1, 2), (2, 5), (3, 8), (4, 12), (5, 12) \), with OLS line \( \hat{y} = -0.3 + 2.7x \). Compute the usual, HC0 and HC1 standard errors of the slope.
HC0 comes out below the usual standard error even though the residuals fan out, because with \( n = 5 \) its downward bias is severe. HC1 corrects that. (HC3 is larger still, 0.668, because the two end points have leverage 0.6.) With five observations none of these deserves much trust; the example shows the mechanics.
In practice it is one extra word. In Python’s statsmodels, smf.ols(...).fit(cov_type="HC1"); in R, lmtest::coeftest(m, vcov = sandwich::vcovHC(m, type = "HC1")); in Stata, regress y x1 x2, robust (or vce(hc3)).
How much do robust standard errors matter?
| Wage equation, \( n = 1{,}000 \) | Level: coef | usual se | robust se | Log: coef | usual se | robust se |
|---|---|---|---|---|---|---|
| educ | 2.301 | 0.179 | 0.203 | 0.1048 | 0.00757 | 0.00736 |
| exper | 0.543 | 0.132 | 0.124 | 0.0301 | 0.00558 | 0.00575 |
| expersq | −0.954 | 0.284 | 0.284 | −0.0563 | 0.01204 | 0.01285 |
| tenure | 0.321 | 0.074 | 0.074 | 0.0154 | 0.00315 | 0.00300 |
| female | −3.357 | 0.667 | 0.675 | −0.1553 | 0.02828 | 0.02831 |
| BP test: LM (\( p \)) | 36.58 (< 0.001) | 10.56 (0.061) | ||||
Robust standard errors are HC1 (from Econometrics Made Simple, Chapter 11). Logs often reduce heteroskedasticity: the level equation fails the BP test overwhelmingly, the log equation only borderline. The biggest correction comes where the variance pattern is strongest: in levels, the robust standard error for education is about 13.5% larger than the usual one. And robust standard errors can go either way: for experience in levels the robust one is smaller.
Small samples: HC1 or HC3?
Robust standard errors rest on large-sample arguments. The book’s simulation, with right-skewed \( x \) and an error standard deviation proportional to \( x \), tests a true null at 5%, 5,000 times for each sample size.
With the usual standard errors the test rejects a true null 17% to 21% of the time, and the problem does not improve as \( n \) grows. All the robust versions converge on 5%. In small samples they differ: at \( n = 30 \), HC1 rejects 13% of the time and HC3 7.9%. The rule of thumb: HC1 is fine in large samples; use HC3 when the sample is small, say below a few hundred, or when a few observations have high leverage.
Robust \( t \) and \( F \) tests
A robust \( t \) statistic is formed exactly like the usual one, with the robust standard error underneath: \( t = (\hat\beta_j – a_j)/\text{se}_{\text{robust}}(\hat\beta_j) \). In large samples it is approximately standard normal under \( H_0 \), and a robust 95% interval is \( \hat\beta_j \pm 1.96\,\text{se}_{\text{robust}} \).
Joint tests need more care. The \( F \) formulas from Step 7, built from \( R^2 \) or the SSR of restricted and unrestricted models, assume homoskedasticity, and there is no robust version of them. A robust test of several restrictions uses the robust variances and covariances of the estimates. The result is a Wald statistic; divided by the number of restrictions \( q \), it is reported as a robust \( F \). Software computes it as soon as you fit with a robust covariance matrix.
In the log-wage equation, the test that experience does not matter (\( \beta_{\text{exper}} = \beta_{\text{expersq}} = 0 \)) gives a robust \( F \) of 15.02 against the usual 15.15: the same conclusion. In the level equation the robust \( F \) is 11.65 against the usual 9.57. Both reject strongly here, but in a closer case the choice could change the verdict. The robust \( t \) for \( H_0: \beta_{\text{educ}} = 0.08 \) in the log equation is 3.37, against 3.27 with the usual standard error.
f_test in statsmodels, waldtest or car::linearHypothesis with a robust vcov in R, test after regress, robust in Stata.Weighted least squares and feasible GLS
Robust standard errors fix inference but leave OLS inefficient. If you know how the variance depends on \( x \), you can do better. Suppose \( \text{Var}(u_i \mid \mathbf{x}_i) = \sigma^2 h_i \) with \( h_i \) known, for example \( h_i = x_{i1} \). Divide every term of the model by \( \sqrt{h_i} \):
The new error has variance \( \sigma^2 h_i/h_i = \sigma^2 \): it is homoskedastic, and the parameters are the same \( \beta \)s. OLS on this transformed equation (which has no ordinary intercept) is BLUE. It is the same as minimising \( \sum \hat{u}_i^2/h_i \): each squared residual gets weight \( 1/h_i \), so noisy observations count for less. This is weighted least squares (WLS), a special case of generalised least squares.
A savings model is \( \text{sav} = \beta_0 + \beta_1\,\text{inc} + u \) with \( \text{Var}(u \mid \text{inc}) = \sigma^2\,\text{inc} \). Write down the transformed equation and the WLS weight.
Richer households, whose saving is noisier, get less weight. The coefficients still estimate \( \beta_0 \) and \( \beta_1 \) of the original model.
In the book’s house-price data, assuming \( \text{Var}(u \mid \mathbf{x}) = \sigma^2\,\text{sqft} \), WLS gives a floor-area coefficient of 0.1367 (standard error 0.0080) against OLS’s 0.1280 (robust standard error 0.0089). Most WLS standard errors are smaller than the robust OLS ones (7.30 against 8.02 for a pool): that is the efficiency gain.
Usually \( h(\mathbf{x}) \) is unknown, and feasible GLS (FGLS) estimates it. A convenient model is \( \text{Var}(u \mid \mathbf{x}) = \sigma^2\exp(\delta_0 + \delta_1 x_1 + \dots + \delta_k x_k) \), which is always positive. Run OLS and save the residuals; regress \( \log(\hat{u}^2) \) on the \( x \) variables and save the fitted values \( \hat{g}_i \); set \( \hat{h}_i = \exp(\hat{g}_i) \); then run WLS with weights \( 1/\hat{h}_i \). On the house data, FGLS gives estimates close to OLS and smaller standard errors: 0.0081 against 0.0089 for floor area, 0.535 against 0.598 for distance, 7.25 against 8.02 for a pool.
The linear probability model is always heteroskedastic
When \( y \) is 0 or 1, OLS estimates a linear probability model, \( P(y = 1 \mid \mathbf{x}) = \beta_0 + \beta_1x_1 + \dots \). A 0/1 variable with probability \( p \) has variance \( p(1-p) \), so
which changes with \( \mathbf{x} \) unless no regressor matters. The LPM is heteroskedastic by construction. In the book’s data on 2,000 loan applications, the Breusch–Pagan statistic is 187.0: a decisive rejection, as theory predicts. The rule is simple: always use robust standard errors with an LPM. WLS with weights \( 1/[\hat{p}(1-\hat{p})] \) fails whenever a fitted probability falls outside 0 to 1, and here 156 of the 2,000 do. That is one reason Step 14 introduces logit and probit.
What to report
Plot the residuals first and ask whether a log is the more natural dependent variable. Then report robust standard errors by default in cross-section work, and say so in the table note: “heteroskedasticity-robust (HC1) standard errors in parentheses”. Use robust \( t \) and Wald tests for every hypothesis. A BP or White test is useful to document the problem or to justify WLS, but a non-rejection is no licence to use the usual standard errors. The same sandwich idea extends to errors correlated over time (Newey–West standard errors, Step 12) and within groups (clustered standard errors, Step 15). For a longer treatment with more examples, read our article Heteroskedasticity: What It Is, Why It Matters, and How to Fix It.
Practise: 6 questions
Try each one on paper first, then check the worked answer.
EasyQ1. A regression with \( k = 3 \) regressors is estimated on \( n = 400 \) observations. Regressing the squared residuals on the three regressors gives \( R^2 = 0.035 \). Carry out the Breusch–Pagan LM test at the 5% level. Show worked answer
Under \( H_0 \) (homoskedasticity), \( LM \sim \chi^2_3 \); the 5% critical value is 7.81.
\( 14.0 > 7.81 \), so reject homoskedasticity (\( p = 0.003 \)).
Conclusion: report robust standard errors, and use the plot to see which variable drives the variance.
EasyQ2. In a simple regression with \( n = 50 \), \( \text{SST}_x = 200 \), \( \text{SSR} = 336 \) and \( \sum (x_i-\bar{x})^2\hat{u}_i^2 = 1{,}800 \). Compute the usual, HC0 and HC1 standard errors of the slope. Show worked answer
HC0: variance \( 1{,}800/200^2 = 0.045 \), se \( = 0.212 \).
HC1: variance \( 0.045 \times 50/48 = 0.0469 \), se \( = 0.217 \).
The robust standard errors are larger, which suggests the biggest squared residuals sit at observations far from \( \bar{x} \).
MediumQ3. A model with \( k = 4 \) regressors is estimated on \( n = 600 \) observations. (a) How many terms would the full White test’s auxiliary regression contain? (b) The special White test, regressing \( \hat{u}^2 \) on \( \hat{y} \) and \( \hat{y}^2 \), gives \( R^2 = 0.012 \). Carry out the test at 5%. Show worked answer
(b) \( LM = 600 \times 0.012 = 7.2 \). The 5% critical value of \( \chi^2_2 \) is 5.99.
\( 7.2 > 5.99 \): reject homoskedasticity (\( p = 0.027 \)).
The special test uses 2 degrees of freedom however many regressors there are, which keeps its power up.
MediumQ4. Food spending is modelled as \( \text{food} = \beta_0 + \beta_1\,\text{inc} + u \) with \( \text{Var}(u \mid \text{inc}) = \sigma^2\,\text{inc}^2 \). Write the transformed equation that WLS estimates, state the weight, and explain what the intercept of the transformed equation estimates. Show worked answer
\( \dfrac{\text{food}_i}{\text{inc}_i} = \beta_0 \dfrac{1}{\text{inc}_i} + \beta_1 + \dfrac{u_i}{\text{inc}_i} \).
The new error has variance \( \sigma^2\text{inc}^2/\text{inc}^2 = \sigma^2 \): homoskedastic.
The WLS weight is \( 1/h_i = 1/\text{inc}_i^2 \).
Twist: regressing the food share on \( 1/\text{inc} \) with an ordinary intercept, the intercept estimates \( \beta_1 \), the marginal propensity to spend on food, and the slope on \( 1/\text{inc} \) estimates \( \beta_0 \).
MediumQ5. Five observations have \( x = 0, 1, 2, 3, 4 \) and error variances \( \sigma_i^2 = \sigma^2\left[1 + (x_i-\bar{x})^2\right] \). Find the true variance of the OLS slope and the value given by the usual formula \( \bar\sigma^2/\text{SST}_x \). By roughly what percentage is the usual standard error wrong? Show worked answer
Variances: \( \sigma^2(5, 2, 1, 2, 5) \).
True: \( \sigma^2(4 \times 5 + 1 \times 2 + 0 + 1 \times 2 + 4 \times 5)/100 = 0.44\sigma^2 \).
Usual: average variance \( 15\sigma^2/5 = 3\sigma^2 \), so \( 3\sigma^2/10 = 0.30\sigma^2 \).
Variance ratio \( 0.44/0.30 = 1.47 \); standard-error ratio \( \sqrt{1.47} = 1.21 \). The usual standard error is about 17% too small (\( 1/1.21 = 0.83 \)), because the noisiest points are the ones far from \( \bar{x} \).
ExamQ6. A wage equation in levels (\( n = 1{,}000 \), five regressors) gives an education coefficient of 2.301 with usual standard error 0.179 and HC1 robust standard error 0.203. The Breusch–Pagan LM statistic on all five regressors is 36.58. (a) State the null hypothesis of the BP test and your conclusion at 5%. [2] (b) Compute the \( t \) statistic for education with each standard error, and a robust 95% confidence interval. [3] (c) The same model with \( \log(\text{wage}) \) gives BP \( LM = 10.56 \). Explain why the log model shows less heteroskedasticity. [2] Show worked answer
(b) Usual \( t = 2.301/0.179 = 12.85 \); robust \( t = 2.301/0.203 = 11.33 \). [M1 A1]
Robust interval: \( 2.301 \pm 1.96 \times 0.203 = [1.90, 2.70] \) dollars per hour per year of education. [A1]
(c) In levels, errors are in dollars, and dollar errors are larger for high earners. A log model makes errors proportional: a 10% surprise is the same size in logs at any wage. [B1] The BP \( p \)-value rises from below 0.001 to 0.061. [B1]
Total: 7 marks.
Check yourself
1. Under heteroskedasticity, with MLR.1–MLR.4 holding, the OLS coefficient estimates are
2. In a Breusch–Pagan test with \( k \) regressors in the auxiliary regression, the LM statistic is
3. If \( \text{Var}(u \mid x) = \sigma^2 x \), the WLS weight for each observation is
Your score: 0 out of 3
The short version
- Heteroskedasticity: \( \text{Var}(u \mid \mathbf{x}) \) depends on \( \mathbf{x} \). Common with income, firm size, wages and education, and group averages.
- OLS stays unbiased and consistent; the usual standard errors and tests are invalid even in large samples, and OLS is not BLUE.
- Detect with plots, Breusch–Pagan (\( nR^2 \sim \chi^2_k \)) and White (squares and cross products, or the special version with \( \hat{y} \) and \( \hat{y}^2 \)). Aim the test at the variable you suspect.
- Robust standard errors replace \( \sigma_i^2 \) with \( \hat{u}_i^2 \). HC1 is standard; HC3 is best in small samples. Robust joint tests are Wald tests computed by software, not \( R^2 \) formulas.
- WLS weights by \( 1/h_i \) when \( \text{Var}(u \mid \mathbf{x}) = \sigma^2h_i \); FGLS estimates \( h_i \) from \( \log(\hat{u}^2) \). The LPM always needs robust standard errors.
- The full chapter in Econometrics Made Simple has the code in Python, R and Stata, more worked examples and a complete set of exercises with answers.
Studying more than one subject? The Complete Book Bundle gives you every Economics, Statistics, Mathematics and Econometrics book in one download.
Further reading on EconTutorials
Related in-depth articles from our blog:
