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

  1. Check the homoscedasticity assumption (constant error variance) of OLS regression.
  2. Guide decisions on whether to use robust standard errors or Weighted Least Squares (WLS).

When to Use

Use Breusch-Pagan When...


Theoretical Background

Hypotheses

Procedure

  1. Fit OLS model, obtain residuals.
  2. Regress squared residuals on predictors.
  3. Test if this regression is significant (LM statistic ~ χ2).

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

  1. Sensitive to normality: Non-normal errors can cause false positives. Use White Test for robustness.
  2. 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.