Sub topic 8
Heteroskedasticity: Detection with Breusch-Pagan and Robust Standard Errors
Assume that you know simple and multiple linear regression, residuals, p-values, and the meaning of a standard error. This chapter focuses on a problem with the error variance, not necessarily with the average relationship between the dependent and independent variables.
What heteroskedasticity means
The multiple regression model is
Y_i = β_0 + β_1X_{1i} + ... + β_kX_{ki} + ε_i
Homoskedasticity means that the conditional variance of the error is constant:
Var(ε_i | X_i) = σ²
Heteroskedasticity means that this variance changes across observations. For example, prediction errors for high-income households may be larger in dollar terms than errors for low-income households.
Heteroskedasticity does not automatically make the ordinary least squares (OLS) coefficient estimates biased. If the regressors are exogenous, the estimates can still be unbiased and consistent. However, OLS is no longer the most efficient linear unbiased estimator, and the usual standard errors are generally wrong. As a result, t-tests, confidence intervals, and F-tests may be unreliable.
A useful distinction is:
- The estimated coefficients describe the fitted conditional mean.
- The standard errors describe uncertainty around those coefficients.
- Heteroskedasticity mainly threatens the second part when conventional OLS standard errors are used.
Detecting it with the Breusch-Pagan test
The Breusch-Pagan test examines whether squared residuals are related to the explanatory variables.
- Estimate the original OLS regression and obtain residuals
e_i. - Regress
e_i²on the original explanatory variables. - Calculate the Lagrange multiplier statistic
LM = nR², wherenis the sample size andR²comes from the auxiliary regression. - Under the null hypothesis of homoskedasticity, the statistic is approximately chi-squared with
kdegrees of freedom, wherekexcludes the intercept.
The hypotheses are:
- Null hypothesis: the error variance is constant.
- Alternative hypothesis: the error variance depends on one or more regressors.
A small p-value leads you to reject homoskedasticity. A large p-value does not prove constant variance. It means that this test did not find enough evidence against it.
The test is sensitive to the variance pattern represented by the auxiliary regression. A residual plot can provide additional evidence, especially when the spread forms a funnel or another systematic pattern.
Robust standard errors
Heteroskedasticity-robust standard errors, often called White or sandwich standard errors, change the estimated covariance matrix. They do not change the fitted coefficients, residuals, or R-squared. They change the standard errors, t-statistics, p-values, and confidence intervals.
import numpy as np
import statsmodels.api as sm
from statsmodels.stats.diagnostic import het_breuschpagan
rng = np.random.default_rng(0)
n = 200
x = rng.normal(size=n)
y = 1.0 + 2.0 * x + rng.normal(size=n) * (1 + np.abs(x))
X = sm.add_constant(x)
model = sm.OLS(y, X).fit()
lm_stat, lm_pvalue, f_stat, f_pvalue = het_breuschpagan(
model.resid, model.model.exog
)
print("Breusch-Pagan p-value:", lm_pvalue)
robust = sm.OLS(y, X).fit(cov_type="HC1")
print("OLS coefficients:", model.params)
print("Robust standard errors:", robust.bse)
print("Robust p-values:", robust.pvalues)HC1 is a finite-sample adjustment often used in applied work. The correction protects inference under fairly general forms of heteroskedasticity, especially in larger samples. It does not repair omitted variables, reverse causality, wrong functional form, or dependence between observations.
If the variance structure is known or can be modeled well, weighted least squares may improve efficiency. Otherwise, robust standard errors are usually the safer correction.
| Finding | Main consequence | Typical response |
|---|---|---|
| Heteroskedastic errors with exogenous regressors | Conventional inference may be invalid | Report robust standard errors |
| Heteroskedastic errors caused by misspecification | Coefficients may also be misleading | Reconsider variables and functional form |
| Known variance pattern | OLS is inefficient | Consider weighted least squares |
Exercise
A regression has a Breusch-Pagan p-value of 0.01. Should you change the OLS coefficients before testing whether a slope differs from zero?
Show answer
No. First retain the OLS coefficient estimates and use heteroskedasticity-robust standard errors for the t-test, unless there is separate evidence of misspecification or endogeneity.