Breusch-Pagan Test
Breusch-Pagan Test
Definition
Core Statement
The Breusch-Pagan Test is a statistical test used to detect heteroscedasticity in a linear regression model. It tests whether the variance of the residuals depends on the values of the independent variables.
Purpose
- Check the homoscedasticity assumption (constant error variance) of OLS regression.
- Guide decisions on whether to use robust standard errors or Weighted Least Squares (WLS).
When to Use
Use Breusch-Pagan When...
- Model is Simple Linear Regression or Multiple Linear Regression.
- You suspect error variance is related to predictor values.
- Residuals vs Fitted plot shows a "funnel" or "fan" shape.
Theoretical Background
Hypotheses
: Error variances are equal (Homoscedasticity). : Error variances are not equal (Heteroscedasticity).
Procedure
- Fit OLS model, obtain residuals.
- Regress squared residuals on predictors.
- Test if this regression is significant (LM statistic ~
).
Visual Alternative
Residuals vs Fitted Plot
A scatter plot of residuals against fitted values.
- Homoscedasticity: Random cloud.
- Heteroscedasticity: Funnel or fan shape (spread increases with fitted value).
Assumptions
Limitations
Pitfalls
- Sensitive to normality: Non-normal errors can cause false positives. Use White Test for robustness.
- Does not tell you the form: Indicates if heteroscedasticity exists, not how variance changes.
Python Implementation
import statsmodels.api as sm
from statsmodels.stats.diagnostic import het_breuschpagan
# Fit OLS Model
X = sm.add_constant(df['X'])
model = sm.OLS(df['Y'], X).fit()
# Breusch-Pagan Test
lm_stat, lm_pval, f_stat, f_pval = het_breuschpagan(model.resid, model.model.exog)
print(f"LM Statistic: {lm_stat:.2f}")
print(f"LM p-value: {lm_pval:.4f}")
if lm_pval < 0.05:
print("Heteroscedasticity detected. Use robust SE or WLS.")
R Implementation
library(lmtest)
model <- lm(Y ~ X, data = df)
# Breusch-Pagan Test
bptest(model)
# If p < 0.05: Heteroscedasticity present.
# Solution: Use robust SE
library(sandwich)
coeftest(model, vcov = vcovHC(model, type = "HC3"))
Interpretation Guide
| Output | Interpretation |
|---|---|
| p < 0.05 | Heteroscedasticity detected. Violates OLS assumption. |
| p > 0.05 | No evidence of heteroscedasticity. Assumption likely met. |
Related Concepts
- White Test - More general heteroscedasticity test.
- Weighted Least Squares (WLS) - Correction method.
- Robust Standard Errors - Alternative correction.