Concepts

  • A response often depends on more than one predictor, and using only one can leave out information that actually matters for explaining it.
    • Example: college GPA may depend on SAT score, credit hours, and study time together, not any one of those alone.
    • Leaving out a predictor that truly matters doesn’t just lose explanatory power — Residual and Sum-of-Squares Proofs’s omitted-term mechanics (and HW 2 - Regression Inference and Diagnostics Problem 2) show it leaves a systematic, non-random pattern in the residuals.
  • The general multiple linear regression (MLR) model adds predictors instead of one: .
    • is the population response plane (a hyperplane once ).
    • The ‘s are unknown population parameters; denotes their least-squares estimate from the sample, exactly as in SLR.
    • The same four error assumptions from Fitting a Simple Linear Regression carry over unchanged: , constant variance , independence across , and (for exact small-sample inference) normality, .
  • “Linear” describes the coefficients, not the geometric shape in — this is why polynomial and interaction terms still count as MLR.
    • is a linear regression model, because it’s linear in even though the curve itself is a parabola in .
    • In R, wrap a derived term like in I() — lm(y ~ x + I(x^2)) — so it’s treated as its own new predictor column rather than literal exponentiation inside the formula syntax.
    • With two raw predictors , a complete second-order model can include ; the cross term is called an interaction and is second order even though neither variable alone is squared.
  • Matrix form packages the whole model as one equation, which is what makes a closed-form solution for predictors possible at all.
    • Stack the model as , where is , is the design matrix (a leading column of ‘s for the intercept, then one column per predictor), is , and is .
    • Minimizing over and setting the matrix derivative to zero gives the normal equations .
    • As long as has full column rank (no predictor is an exact linear combination of the others), is invertible and — the direct generalization of .
    • Fitted values are and residuals are , same definitions as SLR, just with more terms inside .
  • The hat matrix writes the whole fitting step as one linear map of .
    • Define ; substituting into gives — sends the observed responses directly to the fitted values.
    • The residual vector is then — also a linear map of , via instead of .
    • depends only on (the predictor values), never on — the same fact that made SLR’s leverage depend only on the ‘s.
  • ‘s algebraic properties are what make variances and expectations of collapse to clean closed forms, so they’re worth having on hand, not just as trivia.
    • is symmetric, : since , , and is itself symmetric (so its inverse is too), giving back .
    • is idempotent, : , and the middle collapses the expression straight back to — applying the projection twice does nothing new.
    • is also symmetric and idempotent, by the same two facts: directly, and .
    • : the design matrix’s own columns already sit in the space projects onto, so projecting them changes nothing; consequently .
    • , where is the number of estimated parameters (including the intercept) — the trace of the hat matrix always equals exactly the number of parameters fit, regardless of the data.
    • Every diagonal entry satisfies .
  • Why the fitted plane always passes through the centroid — a direct consequence of fitting with an intercept, not a coincidence.
    • Minimizing with respect to gives the normal equation .
    • Substituting and dividing by : .
    • Plugging into the fitted equation then gives exactly — the plane contains the point of means.
  • The variance of the residual vector has a clean matrix form, but it is not simply a diagonal matrix of per-observation variances.
    • Using for a fixed matrix , with and : , using symmetry and idempotence of .
    • Written out, the diagonal entries are — the familiar per-observation residual variance — but the off-diagonal entries are , nonzero covariances: fitted residuals are correlated with each other even though the original ‘s are independent.
    • , using — residuals are unbiased for the true errors on average, same conclusion as SLR.
  • Leverage generalizes directly: is the -th diagonal entry of , and it only ever depends on the predictor values.
    • In simple linear regression this collapses to the familiar closed form , from Regression Diagnostics and Leverage — a special case of the general formula with only one predictor.
    • With predictors there’s no single clean algebraic formula like SLR’s — has to come from the matrix computation (or hatvalues() in R) — but still always holds, generalizing SLR’s “leverages sum to .”
    • The high-leverage flag generalizes the same way: flag observation when exceeds twice the average leverage, — SLR’s cutoff is exactly this with .
  • Polynomial regression is just MLR with derived predictor columns, not a separate technique.
    • fits the matrix framework above directly, with the design matrix’s second column being and third column being — still linear in , so applies unchanged.
    • Because it’s an ordinary MLR fit, every tool above — the hat matrix, its leverage, the cutoff — applies to a polynomial fit exactly as written, just with counting however many polynomial terms (plus intercept) were fit.
  • If the model isn’t linear in the parameters (e.g. ), there’s no closed-form at all — fitting falls back to an iterative numerical search for where , done by computer since there’s no clean algebraic solution.

Practice Problems

  • Problem 1 — polynomial regression as MLR (HW2’s profsalary.txt, , fitting ). Fit the quadratic model, verify , find the leverage cutoff, and compare to the plain linear fit from HW 2 - Regression Inference and Diagnostics Problem 1.

    • Solution.
      • m2 <- lm(Salary ~ Experience + I(Experience^2), data = prof) gives
      • parameters (); sum(hatvalues(m2)) , confirming
      • cutoff ; 18 of the 143 observations exceed it — far more flagged than the linear fit’s handful, since adding a squared term changes which experience values count as “extreme”
      • jumps from (linear, HW2 Problem 1) to (quadratic) — the curvature HW2 Problem 1(g)/(h) found by eye (an upside-down-U residual pattern) is exactly what the squared term captures
      • adjusted , barely below plain — the one added parameter cost almost nothing against the huge gain in explained variation, unlike adding a genuinely useless predictor (see MLR Inference, ANOVA, and Adjusted R-Squared Problem 2)
  • Problem 2 — hat matrix trace and leverage cutoff on a real 4-predictor model (mtcars, , disp, hp, drat, wt, ). Confirm , compute the leverage cutoff, and identify which car is flagged.

    • Solution.
      • model1 <- lm(mpg ~ disp + hp + drat + wt, data = mtcars); (intercept plus 4 predictors)
      • sum(hatvalues(model1)) , confirming
      • cutoff
      • only the Maserati Bora exceeds it, — its combination of disp, hp, drat, wt sits far enough from the other 31 cars’ predictor values to pull extra weight in the fit, regardless of its actual mpg
  • Problem 3 — derive the hat matrix’s symmetry and idempotence from scratch, cold. Show and for .

    • Solution.
      • :
        • , reversing the order of the product’s transpose
        • is symmetric, since , so its inverse is symmetric too:
        • substituting both back in:
      • :
        • the middle factors multiply to :
        • , collapsing the bracketed piece