Sub topic 8
Heteroskedasticity: Detection with Breusch-Pagan and Robust Standard Errors
This chapter assumes you can read a regression table, run a t-test on a slope, and know that OLS chooses coefficients to minimize squared residuals. The previous chapters covered the model and its assumptions. Here we look at one assumption, constant error variance, and what to do when it fails.
What heteroskedasticity means
One OLS assumption is that the error term has the same variance for every observation. This is called homoskedasticity. Heteroskedasticity means the error variance changes across observations. A typical case is a regression of company spending on firm size, where large firms have much more scattered residuals than small ones.
The CFA curriculum separates two types:
- Unconditional heteroskedasticity means the error variance is unrelated to the independent variables. It breaks the equal-variance assumption but causes no major problems for inference.
- Conditional heteroskedasticity means the error variance is related to the level of the independent variables. It is the serious case, and it is what the tests and corrections below target.
What it does to your results
Heteroskedasticity does not make the coefficient estimates biased or inconsistent. It damages the standard errors, and with them everything built on the standard errors.
| Quantity | Effect under conditional heteroskedasticity |
|---|---|
| Slope coefficients | Still unbiased and consistent |
| Standard errors | Biased, usually too small when variance rises with the regressor |
| t-statistics | Often too large, so Type I errors increase |
| F-statistic | Unreliable |
| Confidence intervals | Wrong width, so coverage is not the stated 95% |
The direction can reverse. If the variance is largest where the regressor is near its mean, the standard errors can be too large and you will miss real effects. For the exam, remember the common case: understated standard errors, inflated t-statistics, and too many "significant" coefficients.
Detecting it
Look at the residuals
Plot the residuals, or their squares, against each independent variable and against the fitted values. A fan or funnel shape suggests heteroskedasticity. A plot is a useful first look, but it is subjective. A formal test gives you a decision rule.
The Breusch-Pagan test
The Breusch-Pagan (BP) test checks whether the squared residuals are explained by the independent variables.
- H0: no conditional heteroskedasticity.
- Ha: conditional heteroskedasticity.
The procedure has three steps:
- Fit the original regression and save the residuals.
- Square the residuals and regress them on the original independent variables. Record the R² of this auxiliary regression, written R²_resid.
- Compute the statistic.
BP = n × R²_resid
Under H0, the statistic follows a chi-square distribution with k degrees of freedom, where k is the number of independent variables. The test is one-tailed, right side only. A large statistic means the independent variables explain a lot of the squared-residual variation, which is evidence against constant variance.
Worked example. A regression has n = 120 and k = 3. The auxiliary regression of squared residuals on the three regressors gives R²_resid = 0.08.
- BP = 120 × 0.08 = 9.6.
- The 5% critical value of chi-square with 3 degrees of freedom is 7.815.
- Since 9.6 > 7.815, reject H0. Conditional heteroskedasticity is present.
Running the test in Python
The simulation below makes the error standard deviation proportional to x, so the variance grows with the regressor. The code runs the library test and repeats the calculation by hand to show that the statistic is n × R²_resid.
import numpy as np
import statsmodels.api as sm
from scipy import stats
from statsmodels.stats.diagnostic import het_breuschpagan
rng = np.random.default_rng(0)
n = 200
x = rng.uniform(1.0, 5.0, size=n)
y = 1.0 + 2.0 * x + rng.normal(size=n) * x # error sd grows with x
X = sm.add_constant(x)
model = sm.OLS(y, X).fit()
lm_stat, lm_pvalue, f_stat, f_pvalue = het_breuschpagan(model.resid, X)
print("Library BP statistic:", lm_stat)
print("Library BP p-value: ", lm_pvalue)
# Same test by hand: regress squared residuals on the regressors
aux = sm.OLS(model.resid ** 2, X).fit()
manual_lm = n * aux.rsquared
manual_p = stats.chi2.sf(manual_lm, df=X.shape[1] - 1)
print("Manual BP statistic: ", manual_lm)
print("Manual BP p-value: ", manual_p)The two statistics match. With this design the p-value should be far below 0.05, so you reject H0. The het_breuschpagan function also returns an F-version of the test, which you can ignore for the CFA exam.
What BP can and cannot see
BP detects variance that is linearly related to the regressors. Suppose the error spread depends on |x|, and x is symmetric around zero. Then the squared residuals are nearly uncorrelated with x itself, R²_resid is close to zero, and BP can miss a clear fan shape. A more general check, the White test, also regresses squared residuals on the squares and cross-products of the regressors. It catches curved patterns at the cost of more degrees of freedom. Always pair a formal test with a residual plot.
Correcting it: robust standard errors
The standard fix is robust standard errors, also called White-corrected or heteroskedasticity-consistent standard errors. They recompute the standard errors so that they remain valid when the variance is not constant.
Robust standard errors change only the standard errors, not the coefficients. The slope and intercept estimates are the same as in the original OLS fit. The t-statistics, p-values and confidence intervals use the new standard errors and therefore change.
import numpy as np
import statsmodels.api as sm
rng = np.random.default_rng(0)
n = 200
x = rng.uniform(1.0, 5.0, size=n)
y = 1.0 + 2.0 * x + rng.normal(size=n) * x
X = sm.add_constant(x)
ols = sm.OLS(y, X).fit()
robust = sm.OLS(y, X).fit(cov_type="HC1")
print("Coefficients equal:", np.allclose(ols.params, robust.params))
print("Conventional SE:", ols.bse)
print("Robust SE: ", robust.bse)
print("Conventional t: ", ols.tvalues)
print("Robust t: ", robust.tvalues)Here the conventional slope standard error is typically smaller than the robust one, so the conventional t-statistic is too large. That is the pattern the earlier table described.
The HC labels name variants of the same idea:
- HC0 is White's original estimator.
- HC1 applies a degrees-of-freedom scaling, n / (n − k − 1), and is a common default.
- HC2 and HC3 adjust for leverage and behave better in small samples.
Generalized least squares
The curriculum also mentions generalized least squares (GLS), which rescales the model so the transformed errors have constant variance. When the form of the variance is known, GLS is more efficient than OLS with robust standard errors. In practice the form is rarely known, and a wrong variance model can make results worse. That is why robust standard errors are the usual choice.
Gotchas and edge cases
- Robust standard errors do not fix bias. If the model omits a variable or has the wrong functional form, the coefficients themselves are biased, and robust errors cannot repair that. The misspecification chapter returns to this.
- Misspecification can mimic heteroskedasticity. A missing squared term often leaves a curved pattern in the residuals that looks like a variance problem. Check the functional form before correcting the standard errors.
- Robust errors can be smaller too. Do not assume the correction always shrinks your t-statistics. Report whichever result is correct, not whichever is more convenient.
- Do not rely on the F-statistic. Under conditional heteroskedasticity, the conventional overall F-test is unreliable. Use a robust version of the joint test.
- Heteroskedasticity is not serial correlation. The first concerns changing variance across observations. The next chapter covers correlation of errors over time, which needs different tests and often a different correction.
Summary of the workflow
- Fit the model and plot the residuals.
- Run BP and compare n × R²_resid with the chi-square critical value (k degrees of freedom, right tail).
- If you reject, refit with robust standard errors, leaving the coefficients as they are.
- Re-run your t-tests and confidence intervals with the corrected standard errors.
Exercise
A regression with n = 80 and k = 2 gives R² = 0.50. You regress the squared residuals on the two independent variables and obtain R² = 0.06. The 5% chi-square critical value with 2 degrees of freedom is 5.991. Compute the Breusch-Pagan statistic, state your conclusion, and say what happens to the coefficient estimates and the t-statistics if you apply robust standard errors.
Show answer
BP = n × R²_resid = 80 × 0.06 = 4.8. This is below 5.991, so you fail to reject H0 and find no evidence of conditional heteroskedasticity at the 5% level. The original model's R² of 0.50 is not used in the test. If you did apply robust standard errors anyway, the coefficient estimates would not change, and only the standard errors, t-statistics, p-values and confidence intervals would be recalculated.
Exercise
Why can a regression with conditional heteroskedasticity produce too many statistically significant coefficients, even though the coefficient estimates are unbiased?
Show answer
The estimated standard errors are biased, and in the common case where variance rises with a regressor they are too small. A coefficient divided by an understated standard error gives an inflated t-statistic. The test then rejects a true null hypothesis more often than the chosen significance level allows, which raises the Type I error rate.