2.2.7 · D4Linear & Logistic Regression

Exercises — Assumptions of linear regression

2,724 words12 min readBack to topic

Before we begin, two shared pieces of vocabulary. Every diagnostic on this page reads a residual and leans on the error having mean zero, so let us pin both down in plain words.

Figure — Assumptions of linear regression

Look at the figure: the blue dots are data, the yellow line is the fit , and each red vertical stick is one residual . Everything below is built on reading these sticks against the zero line.


Level 1 — Recognition

Exercise L1.1

The figure below shows three real residual-vs-fitted plots — Plot A, Plot B, Plot C. Match each to the assumption it violates, or say "none violated".

Figure — Assumptions of linear regression
Recall Solution

WHAT we look for: a residual plot is our x-ray. A pattern means a broken assumption; no pattern means healthy. Read each against the dashed zero line.

  • Plot A → none violated. A flat, even band around zero is exactly the picture of good residuals: mean zero, constant spread.
  • Plot B → Linearity violated. The U-shape means the straight line is systematically too high in the middle and too low at the ends — the true relationship is curved. WHY: if were truly linear, residuals would carry no leftover shape.
  • Plot C → Homoscedasticity violated (heteroscedasticity). The funnel means the spread of errors grows with , so is not the same constant everywhere.

Exercise L1.2

State, in one line each, what the symbol says in plain English — and be careful about the first one:

Recall Solution
  • : this is uncorrelatedness — no linear relationship between the two errors. It is the weaker cousin of the Independence assumption. Strictly, zero covariance alone does not guarantee full independence; two variables can be uncorrelated yet still dependent in a nonlinear way. The two notions coincide only when the errors are jointly normal, which is exactly the setting we usually work in — under normality, independence. Plain reading: one observation's error carries no linear information about another's.
  • : Normality — each error is drawn from a bell curve centred at 0 with the same spread . Needed for exact - and -tests, not for unbiased prediction.

Level 2 — Application

Exercise L2.1 (VIF)

You regress predictor on all the other predictors and get . Compute the Variance Inflation Factor and decide if this is a multicollinearity red flag.

Recall Solution

The tool and WHY: Multicollinearity means a predictor is predictable from the others. We measure that predictability with — the fraction of 's variance the other predictors explain. High is redundant.

Decision: sits right at the classic danger threshold. Where does 10 come from? is the factor by which the variance of is multiplied compared to an uncorrelated predictor, so the standard error is inflated by . At that is wider intervals — and corresponds to , i.e. 90% of the predictor is already explained by the others. The "10" rule is an empirical convention (Kutner et al.), not a theorem: it flags the point where inflation becomes large enough to routinely destabilise signs and interpretation. Red flag — investigate/drop/combine or use ridge.

Exercise L2.2 (log-transform fix)

The parent note fits and then a log model (the log here is the natural logarithm, base ). For a house with (sq ft, scaled), give the predicted price from both models.

Recall Solution

Linear model: (i.e. $150k).

Log model (natural log, base ): . To undo a natural log we apply its inverse, the exponential : WHY exponentiate: we modelled , so predictions live in log-space; is the one operation that returns us to dollar-space. The two numbers differ because the log model is a different curve fit to stabilise variance, not the same line.


Level 3 — Analysis

Exercise L3.1 (why OLS variance simplifies)

Let denote the covariance matrix of the error vector — an matrix whose diagonal entries are the per-observation variances and whose off-diagonal entry is . OLS has the general sandwich variance Show that under homoscedasticity + uncorrelated errors this collapses to . Then explain in words what breaks when is not .

Recall Solution

The picture of : healthy errors → constant variance on the diagonal ( repeated) and zeros off-diagonal (no correlation). That is precisely , the identity scaled by .

Substitute : Pull the scalar out and drop : The middle cancels to the identity, leaving the clean .

What breaks otherwise: if has different on its diagonal (heteroscedasticity) or nonzero off-diagonals (correlated errors), no cancellation happens; the sandwich stays messy. OLS still weights every point equally, so it overweights noisy points relative to the optimal weight used by WLS. Result: estimates stay unbiased but become inefficient, and the reported standard errors are simply wrong.

Exercise L3.2 (Durbin–Watson reading)

Three time-series fits report Durbin–Watson statistics , , . For each, state whether independence looks fine and, if not, the sign of the autocorrelation. Also note where the test can be inconclusive.

Recall Solution

The tool and WHY: the Durbin–Watson statistic measures whether consecutive residuals move together. means no autocorrelation; means strong positive autocorrelation (a high residual tends to be followed by another high one); means strong negative autocorrelation (residuals flip sign each step).

The inconclusive region (the standard edge case): the test does not use a single cutoff. It compares against two tabulated critical values, a lower and an upper (both depend on and the number of predictors). The verdict is:

  • → positive autocorrelation (reject independence),
  • (and ) → no evidence of positive autocorrelation,
  • inconclusive — the test cannot decide; gather more data or use a complementary test (e.g. Breusch–Godfrey). The mirror band handles the negative side symmetrically.

Verdicts:

  • : essentially 2 → independence looks fine. Good.
  • : well below any typical positive autocorrelationindependence violated. Standard errors too small, -values too optimistic.
  • : above 3, i.e. beyond the mirror upper band → negative autocorrelation — independence violated in the opposite direction.

Level 4 — Synthesis

Exercise L4.1 (small- diagnosis)

You fit a model with observations. The Q-Q plot (shown below) has points hugging the diagonal in the middle but curling up above the line at the top-right and below at the bottom-left. What does this shape mean, and — crucially — can you trust your -test -values here?

Figure — Assumptions of linear regression
Recall Solution

Read the Q-Q shape: a Q-Q plot puts sorted residual quantiles (y-axis) against theoretical normal quantiles (x-axis). Perfect normality → all points on the 45° line. In the figure the right tail rises above the line (residuals bigger than a normal would allow) and the left tail dips belowheavy tails on both ends, more extreme errors than a bell curve predicts.

Can you trust the -test? With only , no — not safely. The $t$-test relies on normal errors when is small. The Central Limit Theorem rescue needs a reasonably large (typically ); is too small for CLT to smooth heavy tails. Fix: use bootstrap -values or robust regression instead of the raw -test.

Exercise L4.2 (combining two failures)

A dataset predicting income from education shows both a funnel in the residual plot and two predictors "years of schooling" and "highest degree level" with correlation . Name each violated assumption and prescribe one fix per problem, in the right order.

Recall Solution

Two distinct diseases:

  1. Funnel → Homoscedasticity violated. Variance of income grows with education. Fix: transform or WLS with weights .
  2. Correlation 0.95 → Multicollinearity. Schooling years and degree level carry nearly the same information (). Fix: drop one, combine them, or use ridge regression.

Order matters: fix multicollinearity/structure of first (it changes which coefficients exist), then re-examine the residual spread and apply the variance fix — because transforming or reweighting only makes sense once the predictor set is settled.


Level 5 — Mastery

Exercise L5.1 (efficiency loss quantified)

Consider two observations with true error variances and . WLS assigns each observation weight . Compute the WLS weights, then the ratio of weight given to the low-noise point versus the high-noise point. Interpret: how does OLS differ, and why is it inefficient?

Recall Solution

WHY weight by : a point with huge variance is unreliable — it should whisper, not shout, in the fit. WLS listens to each point in inverse proportion to its noise. Weight ratio: . The clean point counts 100× more than the noisy one.

OLS by contrast sets all weights equal (), so it treats the wildly noisy point as equally trustworthy. That equal treatment is exactly why OLS is inefficient under heteroscedasticity: it wastes information by over-listening to noise. (Estimates remain unbiased — see the L3 trap.)

Exercise L5.2 (the ridge trade)

With near-perfect collinearity, so blows up and swings wildly. Ridge solves instead. Take a tiny illustrative case where the smallest eigenvalue of is . Show how adding a ridge penalty changes the effective smallest eigenvalue, and connect this to the Bias-Variance Tradeoff.

Recall Solution

The mechanism: adding shifts every eigenvalue of up by . So the smallest eigenvalue moves from Why this rescues us: the inverse's blow-up is governed by . Before ridge that factor is (wild variance in ). After ridge it is — a 100× reduction in the amplification.

Bias–variance link: ridge shrinks coefficients toward zero. That introduces a small bias (we no longer target the exact OLS solution) but slashes variance (coefficients stop swinging). This is the Bias-Variance Tradeoff in action — we trade a pinch of bias for a large drop in variance, and the overall prediction error falls.