liveBook · Manning

Breusch–Pagan test

As explained in Statistics Every Programmer Needs

het_breuschpagan is a statsmodels function that computes Breusch–Pagan heteroscedasticity test results.

The Breusch–Pagan test checks whether regression-residual variance changes systematically with the independent variables. Constant variance supports reliable standard errors, hypothesis tests, and confidence intervals; changing variance indicates heteroscedasticity. section 4.2.4

The test proceeds by:

  • Regressing the squared residuals from the original model on the independent variables in an auxiliary regression. section 4.2.4
  • Testing the null hypothesis that residuals are homoscedastic. section 4.2.4
  • Rejecting the null when the p-value is below 5%, indicating heteroscedasticity; larger p-values support the constant-variance assumption. section 4.2.4

Python with statsmodels

from statsmodels.stats.diagnostic import het_breuschpagan lm_BreuschPagan = het_breuschpagan(lm.resid, lm.model.exog) print(lm_BreuschPagan[1]) # 0.181071316321208 Because the p-value exceeds 0.05, this result does not indicate heteroscedasticity under the stated decision rule.

How Statistics Every Programmer Needs covers it

How deep it goes
Explains the null hypothesis, auxiliary regression, p-value rule, and statsmodels call, but not the statistic’s full derivation.
Examples
Uses fitted-model residuals, a residuals plot, and a statsmodels output p-value of 0.181071316321208.
What it assumes
Assumes a fitted linear regression with accessible residuals and design matrix; defines homoscedasticity and heteroscedasticity.
What you can do after
Diagnose constant-variance violations with statsmodels and interpret the resulting p-value.
How it connects
Connects linear regression with residuals, homoscedasticity, heteroscedasticity, standard errors, hypothesis tests, and confidence intervals.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.