This page is a workout gym for the five assumptions . Instead of re-defining them, we throw every kind of situation at you and work each one to the end. Before we start, one word we will lean on constantly:
A residual e i is the gap between the true value y i and what your fitted line predicted, y ^ i :
e i = y i − y ^ i
Picture a data dot and the fitted line: the residual is the vertical stick from the dot down (or up) to the line. Positive stick = dot above the line, negative = below. Residuals are the leftovers the model could not explain, so every diagnostic is really a question about their shape.
Definition The OLS line and the averaging bar
⋅ ˉ
When we write x ˉ (say "x-bar") it means the average of all the x values: x ˉ = n 1 ∑ i x i . Likewise y ˉ is the average of the y values. Picture the whole cloud of dots and mark their balance point ( x ˉ , y ˉ ) — that is the pivot the OLS line always passes through.
Ordinary Least Squares picks the intercept β 0 and slope β 1 that make the residual sticks as short as possible in total squared length , ∑ i e i 2 . Solving that minimisation gives the two standard formulas we will reuse:
β ^ 1 = ∑ i ( x i − x ˉ ) 2 ∑ i ( x i − x ˉ ) ( y i − y ˉ ) , β ^ 0 = y ˉ − β ^ 1 x ˉ .
When the data is already centered (x ˉ = 0 and y ˉ = 0 ) these collapse to β ^ 1 = ∑ i x i 2 ∑ i x i y i and β ^ 0 = 0 — the simpler shape we use in Ex 2. See Ordinary Least Squares (OLS) for the full derivation.
Figure s01 (below), what its two panels show. Left panel: a fitted line (teal) with data dots (plum) and their orange residual sticks — this is what a residual is , and here the sticks are tiny so the band is flat (linearity holds, our Cell A). Right panel: the residuals left over when a straight line is forced onto cubic data — they snake up and down in a wave, the linearity-violation fingerprint of Cell B.
Every worked example below fills one row. The columns are the kinds of trouble a regression can hand you.
Cell
Case class
What is being tested
Example
A
Linearity — clean pass
flat residual band
Ex 1
B
Linearity — U-shape fail
curved residuals, cubic truth
Ex 2
C
Homoscedasticity — funnel
growing spread, log fix
Ex 3
D
Independence — time correlation
Durbin–Watson number
Ex 4
E
Normality — heavy tail vs CLT
Q–Q read + does n save you
Ex 5
F
Multicollinearity — near-perfect
VIF blows up, sign flips
Ex 6
G
Degenerate / zero input
one predictor, VIF undefined, det = 0
Ex 7
H
Real-world word problem
pick the right violation & fix
Ex 8
I
Exam twist
high R 2 but assumptions broken
Ex 9
Cells A–I are all covered. Signs (positive/negative residuals), the zero/degenerate input (Ex 7), and the limiting behaviour (VIF → ∞ , DW → 0 , CLT as n → ∞ ) all appear explicitly.
Worked example Ex 1 · A flat residual band
Fit y ^ = 3 + 2 x to five points:
( 1 , 5 ) , ( 2 , 7 ) , ( 3 , 9 ) , ( 4 , 11 ) , ( 5 , 13 ) .
Are the residuals patternless?
Forecast: guess — will the residuals be exactly zero, or wiggle?
Predict each point. y ^ i = 3 + 2 x i gives 5 , 7 , 9 , 11 , 13 .
Why this step? The residual needs y ^ i first — you can't measure a leftover without the prediction.
Subtract. e i = y i − y ^ i = 0 , 0 , 0 , 0 , 0 .
Why this step? This is the definition of residual applied to every row.
Read the plot. All sticks have length zero → a perfectly flat band on the zero line.
Why this step? A flat band = no leftover structure = linearity holds (the ideal in figure s01, left panel ).
Verify: the data literally sits on the line y = 3 + 2 x (each y jumps by 2 when x jumps by 1), so residuals must vanish. Units: dollars minus dollars = dollars, consistent. ✅
Worked example Ex 2 · Fitting a line to a cubic
True world: y = x 3 . We collect x = − 2 , − 1 , 0 , 1 , 2 (no noise) and stubbornly fit a straight line by OLS. Show the residuals form a curve.
Forecast: guess the shape of the residual pattern — line? bowl? wave?
Get the data. y = x 3 = − 8 , − 1 , 0 , 1 , 8 .
Fit OLS line. The x values are symmetric about zero, so their average is x ˉ = 0 ; the y values are also symmetric (− 8 , − 1 , 0 , 1 , 8 ), so y ˉ = 0 . With centered data the OLS formulas from the definition above collapse to β ^ 1 = ∑ i x i 2 ∑ i x i y i and β ^ 0 = 0 . Plug in: β ^ 1 = 4 + 1 + 0 + 1 + 4 ( − 2 ) ( − 8 ) + ( − 1 ) ( − 1 ) + 0 + 1 + 2 ⋅ 8 = 10 34 = 3.4 . So y ^ = 3.4 x .
Why this step? We must fit the wrong model to see how it fails; the centered OLS slope formula was defined up top, so no symbol appears unexplained.
Residuals. e i = x 3 − 3.4 x :
x = − 2 : − 8 + 6.8 = − 1.2 ; x = − 1 : − 1 + 3.4 = 2.4 ; x = 0 : 0 ; x = 1 : − 2.4 ; x = 2 : 1.2 .
Why this step? The sign pattern ( − , + , 0 , − , + ) is the fingerprint — it snakes, it does not stay flat.
Read the plot. Residuals go down–up–down–up: a wave / U-ish curve , not a flat band (figure s01, right panel ).
Why this step? A systematic curve is exactly the linearity-violation signature named in the parent note.
Verify: ∑ e i = − 1.2 + 2.4 + 0 − 2.4 + 1.2 = 0 (OLS residuals always sum to zero when an intercept is fit — a built-in sanity check). ✅ Fix: add an x 3 feature (polynomial regression) and residuals collapse to zero.
Worked example Ex 3 · The growing spread
House prices (y , $1000s) vs area x . Fit gives y ^ = 50 + 0.2 x . Residual ranges:
small houses y ^ ≈ 100 → e ∈ [ − 5 , 5 ] ; big houses y ^ ≈ 500 → e ∈ [ − 50 , 50 ] .
Is variance constant? Does a log transform stabilize it?
Forecast: guess — is the spread growing additively or proportionally with price?
Compare raw spreads. The band at y ^ = 100 has half-width 5 ; at y ^ = 500 it has half-width 50 . The absolute spread grew tenfold.
Why this step? Homoscedasticity means the band width is the same everywhere ; here it clearly grows, so constant variance is already suspect.
Spread as a fraction of the fitted value. At y ^ = 100 : 100 5 = 0.05 . At y ^ = 500 : 500 50 = 0.10 . The relative spread doubles (from 5% to 10% ), and the absolute spread scales even faster with price — both signatures point to variance rising with y ^ .
Why this step? Whether we measure spread absolutely or as a percentage, it is not constant — that is the funnel.
Diagnose. Residual-vs-fitted plot = a funnel opening to the right → heteroscedasticity, not curvature.
Why this step? Distinguishes it from Ex 2 (curve = linearity; funnel = variance).
Apply log . If y = ( fit ) ⋅ ϵ with ϵ multiplicative, then log y = log ( fit ) + log ϵ . A spread that scaled with size becomes an additive constant on the log scale.
Why this step? Log turns "spread proportional to size" into "spread the same size" — variance stabilized.
Verify: absolute half-width goes 5 → 50 (a factor of 10 ) exactly as y ^ goes 100 → 500 (a factor of 5 ) — spread grows at least as fast as price, confirming non-constant variance. So the WLS weight would be w i ∝ 1/ σ i 2 (down-weighting the noisy big houses), and log is the cheap equivalent. ✅
Worked example Ex 4 · Durbin–Watson by hand
Residuals from a 6-day time series (in order): e = 1 , 2 , 3 , − 1 , − 2 , − 3 .
Compute the Durbin–Watson statistic and decide if errors are independent.
Forecast: the residuals drift from + to − smoothly — will DW land near 2 (good) or near 0 (trouble)?
Formula. d = ∑ i = 1 n e i 2 ∑ i = 2 n ( e i − e i − 1 ) 2 .
Why this step? DW compares neighbouring residuals. If today's leftover looks like yesterday's, consecutive differences are small → small d .
Numerator (differences). ( 2 − 1 ) 2 + ( 3 − 2 ) 2 + ( − 1 − 3 ) 2 + ( − 2 + 1 ) 2 + ( − 3 + 2 ) 2 = 1 + 1 + 16 + 1 + 1 = 20 .
Denominator. 1 + 4 + 9 + 1 + 4 + 9 = 28 .
Why this step? Denominator scales by overall residual size so d is unit-free.
Divide. d = 20/28 ≈ 0.714 .
Why this step? d < 1 is the parent note's red flag → positive autocorrelation , independence violated.
Verify: DW ranges [ 0 , 4 ] with 2 = no correlation. Our smooth run-up-then-down gives 0.71 , far below 1 — matches the "trouble" band. Limiting check: perfectly identical consecutive residuals would give numerator 0 ⇒ d = 0 . ✅ Fix: GLS / ARIMA (see Ordinary Least Squares (OLS) vs GLS discussion).
Worked example Ex 5 · Reading a Q–Q plot and deciding
A Q–Q plot of residuals: the middle points hug the 45° reference line, but the top-right points bend above the line. Two scenarios: (a) n = 15 , (b) n = 200 .
Forecast: guess which tail is heavy and whether the small-n case can still trust a t -test.
Decode the deviation. A Q–Q plot puts the sample quantiles (vertical axis) against the normal quantiles (horizontal axis). At the top-right, the sample points sit above the reference line, meaning the largest residuals are bigger than a normal distribution would produce → a heavy right tail , i.e. right-skewed errors.
Why this step? Deviations at the ends of a Q–Q plot are the tails; reading which side pulls away tells you which tail is heavy. (A left tail lighter than normal would instead sit above the line at the bottom-left; here the story is only the right tail.)
Effect on inference. A heavy right tail means a few large residuals dominate β ^ ; t -based intervals can be too narrow and p -values off.
Why this step? t -tests assume normal errors; a broken assumption makes p -values only approximate.
Apply the CLT rule. The sampling distribution of β ^ → normal as n → ∞ .
(a) n = 15 : too small — CLT has not "kicked in", use bootstrap p -values.
(b) n = 200 > 30 – 50 : CLT saves you, t -test valid.
Why this step? Normality of errors is only needed as a shortcut to normality of β ^ ; enough data delivers that directly.
Verify: the threshold n > 30 –50 is the parent note's rule; 200 clears it, 15 does not. No numeric coefficient here, only a decision. ✅
Worked example Ex 6 · VIF explosion and a sign flip
Two predictors: area in sq ft X 1 and area in sq m X 2 = 0.0929 X 1 plus tiny rounding noise giving R 2 2 = 0.999 when X 2 is regressed on X 1 . Compute VIF.
Forecast: guess the VIF — single digits, or off the chart?
Formula. VIF j = 1 − R j 2 1 , with R j 2 from regressing X j on the other predictors.
Why this step? R j 2 near 1 means X j is almost predictable from the rest — the redundancy we fear.
Plug in. VIF 2 = 1 − 0.999 1 = 0.001 1 = 1000 .
Why this step? 1000 ≫ 10 , the parent note's "serious multicollinearity" line.
Interpret. Standard error of β ^ 2 scales as VIF ≈ 31.6 × larger than with no collinearity → huge, unstable coefficients that can flip sign on tiny data changes.
Why this step? This is the 1/ λ m i n blow-up from the parent derivation made concrete.
Verify: as R j 2 → 1 , VIF → ∞ (limiting behaviour). Check the standard-error inflation: 1000 ≈ 31.62 . ✅ Fix: drop one area column, or ridge to stabilize.
Worked example Ex 7 · A constant column kills the fit
You accidentally add a column that is all the same value: X 2 = ( 7 , 7 , 7 , 7 ) , alongside intercept and X 1 . What happens to det ( X T X ) , and to VIF?
Forecast: guess — does the model just ignore it, or break?
Spot the duplication. A constant column equals 7 × the intercept column of 1s. So X 2 = 7 ⋅ 1 — a perfect linear combination.
Why this step? Multicollinearity's extreme case is exact dependence.
Determinant. Two proportional columns make X T X singular: det ( X T X ) = 0 .
Why this step? ( X T X ) − 1 needs a nonzero determinant; zero means no unique OLS solution .
VIF. Regressing X 2 on the intercept gives R 2 2 = 1 ⇒ VIF = 1 − 1 1 = 0 1 = undefined / infinite .
Why this step? This is the limiting boundary of Ex 6 — collinearity taken to its breaking point.
Verify: a 2 × 2 example — columns [ 1 1 ] and [ 7 7 ] give matrix [ 2 14 14 98 ] , det = 2 ⋅ 98 − 1 4 2 = 196 − 196 = 0 . ✅ Fix: drop the constant/degenerate column before fitting.
Worked example Ex 8 · Which assumption is broken?
A hospital predicts recovery time from patient age. Data: each patient measured weekly for 8 weeks (repeated rows per patient), and the residual spread is wider for older patients . Name every violated assumption and its fix.
Forecast: guess how many of the five assumptions are in trouble.
Repeated measures on the same person → errors within a patient are correlated → Independence violated.
Why this step? Cov ( ϵ i , ϵ j ) = 0 for rows of the same patient.
Spread wider for older patients → Homoscedasticity violated (a funnel keyed to age).
Why this step? Var ( ϵ i ∣ X i ) changes with X i .
Fixes. Independence → mixed-effects / GLS ; heteroscedasticity → WLS with w i = 1/ σ i 2 or log-transform recovery time.
Why this step? Each fix targets the specific broken clause, per the summary table.
Verify: count = two violations (Independence + Homoscedasticity); Linearity, Normality, Multicollinearity are not implicated by the story. Units: recovery time (days) stays days after log only if you exponentiate back. ✅
Worked example Ex 9 · The seductive
R 2
A student fits y = x 3 data (from Ex 2) with the line y ^ = 3.4 x and reports a high R 2 , concluding "assumptions hold." Compute the true R 2 and expose the fallacy.
Forecast: can a curved-residual model still score close to 0.9 ?
R 2 formula. R 2 = 1 − ∑ ( y i − y ˉ ) 2 ∑ e i 2 .
Why this step? R 2 measures variance explained, nothing about residual shape .
Numerator (SSE). From Ex 2, e = − 1.2 , 2.4 , 0 , − 2.4 , 1.2 ⇒ ∑ e i 2 = 1.44 + 5.76 + 0 + 5.76 + 1.44 = 14.4 .
Denominator (SST). y ˉ = 0 , y = − 8 , − 1 , 0 , 1 , 8 ⇒ ∑ y i 2 = 64 + 1 + 0 + 1 + 64 = 130 .
Divide. R 2 = 1 − 14.4/130 = 1 − 0.1108 ≈ 0.889 .
Why this step? A high 0.889 despite the wave-shaped residuals of Ex 2 — the fit "looks good" yet linearity is clearly broken.
Verify: R 2 ≈ 0.889 > 0.8 while residuals form a curve → confirms the parent-note mistake callout: big R 2 never certifies assumptions . Always read the residual plot. ✅
Recall Quick self-test
Durbin–Watson for residuals 1 , 2 , 3 , − 1 , − 2 , − 3 ? ::: d = 20/28 ≈ 0.714 → independence violated.
VIF when R j 2 = 0.999 ? ::: 1/ ( 1 − 0.999 ) = 1000 → serious multicollinearity.
R 2 of the line 3.4 x fit to x 3 data? ::: ≈ 0.889 — high yet linearity is broken.
Funnel vs curve in a residual plot? ::: funnel = heteroscedasticity; curve = nonlinearity.
Mnemonic Matrix in one breath
A ll-flat, B owl-curve, C one-funnel, D rift-DW, E dges-QQ, F at-VIF, G one-degenerate, H ospital-two-breaks, I mpostor-R 2 .
See also: Residual Analysis · Hypothesis Testing in Regression · Generalized Linear Models (GLMs) .