liveBook · Manning

Regression assumption

As explained in Statistics Every Programmer Needs

A regression assumption is a condition about the data, errors, or model structure required for valid regression inference.

A regression assumption is a condition about the data, errors, or model structure that must hold for linear-regression results to be reliable and interpretable. Validate these conditions before trusting coefficients, significance tests, goodness-of-fit measures, or predictions. section 4.0 section 4.3

Check the following conditions after fitting the model:

  • Linearity requires the predictor–response relationship to be adequately represented by a straight line; inspect a residuals plot for random scatter around zero. section 4.2.4
  • Independence requires residuals to be uncorrelated with one another; the Durbin–Watson statistic provides a diagnostic check. section 4.2.4
  • Homoscedasticity requires residual variance to remain consistent; the Breusch–Pagan test checks for changing variance. section 4.3 section 4.2.4
  • Normality requires normally distributed residuals; use a Q–Q plot or the Jarque–Bera test to assess it. section 4.2.4

A practical validation sequence

Fit the regression, inspect the data for outliers and normality, plot fitted values against residuals, and run diagnostic tests. A residuals plot without a curve or funnel pattern supports linearity; Durbin–Watson checks independence, Breusch–Pagan checks variance consistency, and a Q–Q plot or Jarque–Bera test checks residual normality. section 4.2 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

Plot fitted values against residuals with a horizontal zero line to visually assess whether the linearity assumption is plausible. section 4.2.4

How Statistics Every Programmer Needs covers it

How deep it goes
Defines four conditions and gives visual and statistical diagnostics, including residual plots, Durbin–Watson, Breusch–Pagan, and Jarque–Bera tests.
Examples
Uses residuals plots, Q–Q plots, Durbin–Watson, Breusch–Pagan, and Jarque–Bera diagnostics on a real two-variable data set.
What it assumes
Assumes basic regression concepts while teaching the conditions, exploratory checks, and diagnostic procedures needed for validation.
What you can do after
Diagnose regression reliability with plots and tests before interpreting coefficients, significance, fit, or predictions.
How it connects
Connects linear regression with residuals, outliers, normality, homoscedasticity, independence, and goodness of fit.

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.