viewof problem = html`<select style="font-size:15px;padding:4px 8px">
<option value="ok" selected>Nothing — assumptions met</option>
<option value="hetero">Heteroscedasticity (spread grows)</option>
<option value="nonlin">Non-linearity (curved relationship)</option>
<option value="outlier">An influential outlier</option>
</select>`Regression Assumptions & Diagnostics
Info sheet · Statistics for Psychology & Neuroscience
Warning✎ Editing notes — to do / to check
Working notes for the author — not shown to students once collapsed; remove before publishing.
- [ ]
What you’ll get from this sheet
Regression, like any test, rests on assumptions — some familiar from ANOVA, some new. By the end you should be able to:
- List the core assumptions of regression.
- Read the four diagnostic plots R gives you.
- Name the formal tests (Shapiro–Wilk, NCV, VIF).
Regression assumes independence, normal residuals, constant variance (homoscedasticity), linearity, and no strong multicollinearity. Calling plot(model) gives four diagnostic plots to check them by eye; Shapiro–Wilk (normality), the NCV test (constant variance), and VIF (multicollinearity) back them with numbers.
The assumptions
Three are carried over from ANOVA: independence of observations, normality of the residuals, and homogeneity of variance (the residuals should have constant spread). Two are new to regression: linearity (the relationship really is a straight line / plane), and no strong multicollinearity (predictors shouldn’t be near‑duplicates of one another). Note it’s the residuals that must be normal — not the raw variables.
Read the diagnostic plots
The neat R trick: call plot(model) and you get four diagnostic plots. The most useful is Residuals vs Fitted — it should look like a formless, even band around zero. Departures have signatures. Pick a problem below and watch the fitted line (left) and its residual plot (right) change.
The trick is that each violation has a look. A good model shows a shapeless band. Heteroscedasticity fans out. Non‑linearity bends the residuals into a curve. An influential outlier sits alone, far from the pack, tugging the line. Learning to spot these by eye is most of the skill — the formal tests just confirm what the plot suggests.
See it in code
import statsmodels.api as sm
import statsmodels.formula.api as smf
m = smf.ols("y ~ x", data=df).fit()
sm.qqplot(m.resid, line="s") # normality of residuals
sm.stats.diagnostic.het_breuschpagan(m.resid, m.model.exog) # heteroscedasticity
# statsmodels.stats.outliers_influence.variance_inflation_factor(...) for VIFm = fitlm(x, y);
plotDiagnostics(m, 'cooksdistance') % influential points
plotResiduals(m, 'fitted') % residuals vs fitted (spread / curvature)The R tab runs live (including the four plot(m) diagnostics); Python and MATLAB are static references.
TipCheck your understanding
Your Residuals‑vs‑Fitted plot fans out — a narrow spread at low fitted values, a wide spread at high ones. Which assumption is broken, and what confirms it?
That fanning shape is heteroscedasticity — the constant‑variance (homoscedasticity) assumption is violated; the residuals’ spread depends on the fitted value. The NCV (non‑constant variance / Breusch–Pagan) test confirms it: p < .05 means non‑constant variance. Common fixes: transform the outcome (e.g. log price), or use heteroscedasticity‑robust standard errors.
The four plot(model) panels each target a different assumption — don’t read them all as “normality.” A curved Residuals vs Fitted signals non‑linearity (add a term or transform); a fanning one signals heteroscedasticity; the Normal Q‑Q plot checks residual normality; and a point far to the right on Residuals vs Leverage is influential (check Cook’s distance). Real datasets like London housing rarely pass everything cleanly — deciding what matters is judgment, not a pass/fail gate.
Where this shows up next
Next: choosing which predictors belong in the model, and evaluating overall fit. See Chapter (Correlation & Regression) for the full London‑housing diagnostics walkthrough.