Linear Models
The organizing claim: regression is projection, and the whole course is the hat matrix viewed from different angles — geometry (track 2 §2 cashed in), inference (track 3’s pivots on its diagonal), computation (QR/SVD/Cholesky), diagnostics (), model selection ( = df), and shrinkage (modify ‘s eigenvalues). The second load-bearing idea: every multiple-regression coefficient is a simple regression on an adjusted variable — which explains both what coefficients mean and why correlated predictors ruin them.
1. The frame
- The target is the regression function ; the linear model is its first-order Taylor approximation — almost never the truth, almost always the right amount of model for the data you have. Watch ; basis expansions buy flexibility while staying linear in .
- The original “regression”: for bivariate normal (mother, daughter) heights with correlation ,
— the prediction is shrunk toward the mean by . Regression to the mean is a property of conditioning, not a causal force.
- Geometric view of the humble t-test: write = projection onto + residual. The t statistic is monotone in between and :
Under , is uniform on the sphere — tests are statements about angles. This picture scales to everything below.
Core competency set
- State and the Taylor justification for linearity; the regression-to-the-mean formula and its non-causal reading.
- Re-derive the t-test-as-angle picture.
2. The assumptions ladder
Least squares makes sense at three levels; each rung buys more:
| Rung | Assumption | What you get |
|---|---|---|
| 0 | none | pure approximation: minimizes , fit = projection |
| 1 | , , fixed | unbiasedness, , Gauss–Markov |
| 2 | exact distributions: Gaussian, t/F inference (track 3’s pivots) |
- Rung 0 is track 2 §2 verbatim: normal equations ⟺ residual ⊥ columns.
- Rung 1’s variance, derived from the definition of covariance. The estimator is the normal-equations solution from rung 0, ; substitute the rung-1 model (so a true exists) and distribute:
The first term collapses since :
This is a rung-1 identity, not a definition — splits into truth plus a linear function of the noise (at rung 0 there is no true and the split is meaningless). All the sampling variability lives in that second piece. So the estimation error is a fixed linear image of the noise, with ( is fixed, so is constant). The covariance of a linear image of a random vector is :
Pull out the scalar and collapse the middle, using symmetric and :
Simple-regression special case, to see what the matrix hides. The slope is a linear combination of the responses, with . The are independent with variance , so variance pulls through the squared weights:
Evaluate — the denominator is common to every , so it squares out and one power cancels against the numerator sum:
giving . Spread-out ‘s are leverage: the denominator is the design’s information about the slope. (Fisher information arithmetic from track 3, in design language.)
- Rung 2: with , unbiased, and — the track-1 pivot architecture assembled for coefficients.
Core competency set
- Recite the ladder and what each rung buys; derive and the simple-slope variance.
- Say why spread in is the design’s information.
3. Estimability and Gauss–Markov
When is rank-deficient (), is still unique but is not ( for any also solves).
- A linear function is estimable ⟺ lies in the row space of ⟺ for some , and then is a linear unbiased estimate. (One-way ANOVA: and the are not estimable; the contrast is — differences of fits are unique even when parameters aren’t.)
- Fixes, roughly equivalent: restrict to estimable functions; impose side conditions ( — must be non-estimable constraints, enough to reach rank without shrinking the model); reparametrize to full rank.
- Identifiability is the underlying concept: identifiable ⟺ ⟺ full column rank. Don’t estimate what isn’t identified — you don’t know what you’re estimating. (: never identifiable without further structure.)
Gauss–Markov theorem. Under rung 1, among all linear unbiased estimates of an estimable , the least-squares one has the smallest variance (BLUE). The proof is the orthogonal-split move (track 2 §6’s min-norm twin): write any competitor as the LS estimate plus an orthogonal piece, and show the piece only adds variance.
A linear estimate is . Unbiasedness for every pins down a condition on :
Its variance, since :
Split orthogonally into its projection onto the column space and the remainder: with and . Two facts make the split pay. First, the remainder is invisible to the constraint: means , so — the projection alone already satisfies unbiasedness, and is exactly the least-squares estimate. Second, the remainder is orthogonal to the projection, so Pythagoras splits the norm:
Multiply by and drop the non-negative remainder term:
with equality iff . The off-column-space part of any competitor is pure variance and buys no unbiasedness — same structure as the min-norm argument (track 2 §6): split orthogonally, one part does the work, the other is pure cost.
Implications
- BLUE is a linear, unbiased crown — biased estimators (ridge, §8) can and do beat it in MSE; this is track 3’s Cramér–Rao loophole, now concrete.
- Estimability via SVD: — contrasts along small singular directions are barely estimable; at , not at all. Estimability is quantitative, not binary.
Core competency set
- Define estimable/identifiable; produce the ANOVA contrast example.
- Run the Gauss–Markov projection proof and name its track-2 twin.
4. Computation: QR, and what MGS teaches about coefficients
- Solve LS by orthogonalizing, never by inverting: ; with triangular, back-substitute and . Methods: Householder reflections (; map each column to ), Givens rotations (zero one entry at a time — wins on sparse ), modified Gram–Schmidt (orthogonalize against each new immediately — numerically safer than classical GS).
- Never form : squaring squares its condition number (track 2 §6) — normal-equation methods need double precision to match QR. QR also hands you the Cholesky of for free ().
- Rank deficiency in practice: pivot columns by size; declare pseudo-rank when (machine-epsilon scaled); standardize columns first.
The payoff theorem — what Gram–Schmidt means statistically:
where is with the other predictors regressed out.
- Each multiple-regression coefficient is a simple regression on the adjusted variable — “the effect of after accounting for the others” is literal, not a figure of speech.
- And the variance formula is the whole collinearity story: correlated predictors shrink , blowing up . Orthogonal predictors ⟹ multiple = univariate.
- Numbers — two standardized predictors with correlation :
At : variances inflated by , and positively correlated predictors get negatively correlated coefficients — the seesaw you see in real fits. (VIF is exactly this diagonal, per variable.)
Implications — what falls out of adjust-then-regress:
- Omitted-variable bias has a formula: dropping a correlated predictor changes what the kept coefficients mean — they absorb the omitted variable’s effect through the correlation. “Effect of ” is always relative to what else was adjusted for.
- Forward stepwise is just this move repeated: at each step, regress on each adjusted candidate and take the best — one MGS sweep per step (§7).
- The standing counterexample — the suppressor: a predictor with coefficient ≈ 0 univariately can be strong and significant multivariately. Picture: two clusters offset by a binary , each with a clean – slope; the marginal regression must span both clumps and flattens to nothing, but adjusting for recovers the within-cluster slope. Univariate screening can discard jointly essential variables — and the reverse seesaw means jointly insignificant t-stats can hide a strong pair (drop both and the model collapses).
Core competency set
- Name the three QR routes and when each wins; state why normal equations are numerically forbidden.
- Recite the adjusted-variable theorem for and its variance; run the numbers and the coefficient-seesaw implication.
5. The hat matrix: fits, residuals, leverage, influence
; , . Symmetric idempotent (track 2’s projection test), (cyclic trace), eigenvalues = ones and zeros.
- Covariances under rung 1: , , . Variance is conserved and split: a point’s variance goes to its fit or its residual — near 1 means the fit chases the point and the residual goes blind to gross errors there.
- Leverage is Mahalanobis distance. Split the design into the intercept column and the centered rest, , where centering means (each non-intercept column has mean zero). The cross-block vanishes, so is block diagonal and inverts block-by-block:
Write observation ‘s row as and form the leverage; the block-diagonal inverse splits the quadratic form into the intercept piece and the centered piece:
Factor out via the sample covariance , so that :
— the quadratic form is the Mahalanobis distance to the center of the -cloud.
— leverage is distance from the center of the -cloud in the metric of its shape. The picture to hold: an elongated cloud of -points with concentric covariance ellipses — a point at the tip of the long axis can sit far from with modest leverage, while a point the same Euclidean distance off the short axis has huge leverage. Rules of thumb: average is ; flag ; dread .
- Leave-one-out is free. Removing observation is a rank-one downdate of ; Sherman–Morrison–Woodbury inverts it from the full inverse you already have:
Pushing this through the fit gives the two identities to keep:
is literally the weight the fit puts on a point’s own — self-influence. The jackknife residual exposes what the raw residual hides at high leverage.
- Standardized residuals ; Cook’s distance packages leverage × outlyingness:
Numbers: , , : — a moderately outlying point at moderately high leverage already moves the whole fit by half a standard-error ball. High leverage is good when the point agrees with the model (free precision) and poison when it doesn’t — Cook’s distance is the arbiter.
- Residual plots: structure in residuals vs fits/covariates = missing mean structure or non-constant variance; fix with transformations, WLS (§9), or basis expansion; test lack-of-fit by F against the saturated group-means model.
Implications — what falls out of the hat matrix:
- LOOCV is closed-form for linear smoothers — the jackknife residual makes “refit times” a single fit; the same identity underlies GCV and fast influence diagnostics.
- High-leverage gross errors are invisible in raw residuals: the fit chases the point (), so always read standardized or jackknife residuals, never raw ones, at high leverage.
- Good leverage is free sample size: a high- point consistent with the model tightens every coefficient — efficiency from design, the §2 spread-is-leverage fact at the level of single points.
Core competency set
- Recite ‘s properties and the covariance split; narrate “variance goes to fit or residual.”
- Derive leverage-as-Mahalanobis (block split) and the LOO identity’s meaning; compute Cook’s distance from and .
6. The SVD view: PCA, collinearity, and where variance hides
(track 2 §6 working at full tilt):
- — regression is trivial in the singular basis: project on each , divide by . Small ⟹ that coordinate’s noise is amplified by ; rotating back by smears the variance across all coefficients. This is collinearity, exactly.
- : the well-estimated contrasts live along big singular directions.
- PCA = SVD of the centered : — columns of = principal directions, variances . (Uncentered SVD finds directions through the origin, not directions of variance — centering is not optional.) Equivalent characterizations, same Lagrange/eigen computation: max-variance directions of ⟺ best-fitting affine hyperplane (closest rank- manifold, ).
- Collinearity detection: scale columns to equal norm, then read the small singular values and their ‘s — large entries name the involved variables.
- Total least squares (errors in too): stack , SVD, kill the last singular value — a “skew projection” for attribution problems; for pure prediction keep OLS (you’ll only have noisy at test time anyway).
Core competency set
- Write and tell the variance-amplification story.
- State PCA = SVD-of-centered-X with both characterizations; explain why centering matters.
7. Model selection and the bias–variance ledger
-
The decomposition — add-and-subtract twice, the cross-terms dying for two different reasons. Setup: a new point with , independent of the training set that built ; abbreviate , .
First, add-and-subtract inside the prediction error and expand the square into three terms:
The first term is . The cross-term dies because the new point’s noise is independent of (which saw only ) and has mean zero, so . Left with:
Second, add-and-subtract the average fit inside the remaining term and expand:
(this cross-term dies by definition of the mean: the factor is constant in , and ). Assembled:
- Training error lies: is biased down for Err and monotone in complexity. The correction is priced by degrees of freedom:
— how much the fit eavesdrops on its own noise. For linear smoothers (OLS: ; interpolation: ). restores unbiasedness; AIC is its likelihood twin.
- Search procedures: best subset (combinatorial; aggressive — pays hidden df for the hunt, overfits noisy problems), forward stepwise (one MGS sweep finds the next variable: regress on each adjusted candidate), lasso (§8 — searches and shrinks at once). Use CV to pick the size , then refit the chosen size on all data; CV’s standard errors are optimistic.
- Multiple-testing guard rails when reading coefficient t-stats: Bonferroni ; and remember the §4 seesaw — correlated predictors can all look insignificant while jointly essential.
Core competency set
- Run the bias–variance derivation and name the move; define df by the covariance formula and compute it for OLS.
- Explain why RSS can’t select models and what /CV each fix.
8. Shrinkage: ridge and lasso
Ridge ( — scale the columns first; not equivariant):
- Closed form ; substitute the SVD and watch it diagonalize. Write each piece in the singular basis, using so that :
Invert (it’s , so the inverse just inverts the diagonal block) and multiply by , collapsing :
The middle factor is diagonal with entries , so applying to :
Ridge shrinks each principal coordinate smoothly by :
— big- directions barely touched, small- (high-variance) directions crushed. Ridge is targeted variance repair for exactly the directions §6 diagnosed. One SVD gives the whole -path. .
- always lies in the row space of (compare min-norm, track 2).
Lasso (): selection + shrinkage.
- The stationarity conditions are the working object: on the active set , every active variable’s correlation with the residual is tied at , inactive ones below:
Consequences: the path is piecewise linear in (LARS exploits this); the first variable to enter is and .
- Coordinate descent = soft thresholding. Take one standardized predictor (, so its OLS coefficient is ); the lasso objective in that one coordinate reduces to . Differentiate away from the kink, where :
Solve in each sign branch and check the sign is consistent:
When neither branch is consistent, so the minimum sits at the non-differentiable kink . Assembled into one formula:
Numbers: ; — shrink the survivors, kill the small.
— slide toward zero by , clip at zero. The picture to hold: the soft-threshold function — a 45° line with a flat dead zone of width at the origin — vs ridge’s uniformly tilted line (shrink everything, zero nothing) and best subset’s hard threshold (keep or kill). Multiple predictors: cycle, each time soft-thresholding the simple coefficient on the partial residual. Warm starts down a -grid + strong rules ⟹ the fast path algorithm everyone actually uses.
- df(lasso) ≈ — remarkably, the post-search shrinkage pays back the df spent hunting (best subset doesn’t; that’s why aggressive selection loses on noisy data). Relaxed lasso: refit (or blend) OLS on the active set to undo over-shrinkage.
PCR vs PLS vs ridge: PCR hard-thresholds principal components, ridge shrinks them smoothly, PLS lets pick directions (maximizes ). Ridge is usually the well-behaved default.
Implications — what falls out of shrinkage:
- Every penalty is a prior (track 7 §3 makes it exact): ridge ↔ Gaussian, lasso ↔ Laplace. Choosing a regularizer is choosing what you believe about coefficients.
- The df ledger explains the selection-method ranking on noisy data: best subset spends df hunting and keeps unshrunk coefficients (high variance); lasso hunts but then shrinks, paying the hunt back — which is why df(lasso) ≈ and why it beats subset selection away from the low-noise regime.
- Ridge never zeroes, lasso zeroes exactly (the dead zone) — use ridge for correlated groups you want averaged, lasso when you need a short list; relaxed lasso splits the difference by refitting the survivors.
Core competency set
- Write ridge’s SVD shrinkage factor and its df; explain “targeted variance repair.”
- State the lasso stationarity conditions and read off path-linearity and ; derive soft thresholding.
- Compare df accounting: subset vs lasso vs ridge.
9. Weighted least squares and robustness
Correlated/heteroscedastic errors (): whiten, then OLS. Factor (Cholesky, track 2 §5) and set , so the transformed errors are white:
Apply to the model and run OLS on . The transformed objective is a -weighted version of the original, via :
Minimizing is OLS on the transformed data, so its normal equations become, using again:
- = MLE under Gaussian errors; scaling of cancels. Diagonal = weights (e.g. an average of raw points ⟹ , identical to OLS on the raw data). Mixed-effects/longitudinal structure ⟹ block-correlation .
Outliers in (quadratic loss amplifies them):
- Huber/M-estimation: quadratic near 0, linear beyond ; fit by iteratively reweighted LS; keeps 95% Gaussian efficiency. The fitted weights are themselves the diagnostic.
- L1 / quantile (pinball) regression: population minimizer satisfies — gives the conditional median, general gives conditional quantiles.
- LMS/LTS: trim the largest residuals; breakdown point ~50% (half the data can be arbitrarily corrupted); LTS preferred for efficiency.
- Interpretation guard rails: a strong coefficient can be a proxy for an unmeasured cause (Tukey’s warning — undetectable from inside the model); with observational data, coefficients are comparisons across units, not effects of intervening. That gap is track 9’s whole subject.
Core competency set
- Run the whitening derivation; map heteroscedasticity to weights and averages to .
- Match each robust method to its failure mode; derive the pinball-quantile connection.
10. Memorize cold
The instant-recall layer — these should cost nothing to produce; the fluency flashcards drill exactly this list.
- The ladder: rung 0 projection / rung 1 Gauss–Markov / rung 2 t & F.
- ; ; ; .
- Estimable ⟺ ∈ row space of ; Gauss–Markov: is BLUE (projection proof).
- Adjusted-variable theorem: , ; ⟹ ~5.3× variance inflation, coefficient seesaw.
- : symmetric idempotent, ; , ; ; flag .
- LOO: ; Cook’s ; SMW for rank-one updates.
- SVD regression: ; ; PCA = SVD of centered .
- Bias–variance: ; ; .
- Ridge: ; SVD factor ; .
- Lasso: on the active set; ; soft threshold ; df ≈ .
- WLS: whiten via ; ; Huber ; pinball ⟹ conditional -quantile.
- Named moves: adjust-then-regress (MGS, stepwise, partial coefficients); split-orthogonally-and-drop (Gauss–Markov, min-norm); whiten-then-OLS; rank-one-update (SMW/LOO); add-and-subtract (bias–variance — fourth appearance); eavesdropping-df (covariance definition).