Homoscedasticity is the regression condition that residual variability remains consistent across all predictor values or fitted values. When residual spread changes systematically, heteroscedasticity can produce inefficient estimates, biased standard errors, and unreliable hypothesis tests or confidence intervals. section 4.2.4
Assess homoscedasticity as part of regression assumption checking:
- Plot residuals against fitted values and look for changing spread or a systematic pattern. section 4.2.4
- Apply the Breusch–Pagan test, whose null hypothesis states that residuals have constant variance. section 4.2.4
- Use a p-value below 5% to reject homoscedasticity and conclude that residual variance is heterogeneous; a larger p-value does not reject constant variance. section 4.2.4
Breusch–Pagan diagnostic in Python
With a fitted statsmodels regression named lm, run het_breuschpagan(lm.resid, lm.model.exog) and inspect element 1 of the result. The reported p-value, 0.181071316321208, exceeds 0.05, so the test does not reject constant residual variance. section 4.2.4
>>> plt.scatter(lm.fittedvalues, lm.resid) #1
>>> plt.axhline(y = 0, color = 'red',
>>> linestyle = '--') #2
>>> plt.title('Residuals Plot') #3
>>> plt.xlabel('Fitted Values') #4
>>> plt.ylabel('Residuals') #5
>>> plt.show() #6
Use the residuals-versus-fitted-values plot to inspect whether residual spread stays approximately constant across the regression’s fitted values. section 4.2.4


