Concepts
- Least squares doesn’t just hand you a slope and intercept — the way it chooses them forces the residuals to satisfy a few exact cancellation identities.
- Those identities are why the total variation in splits cleanly into explained and unexplained pieces further down.
- So ANOVA and (covered in a later note) are consequences of least squares, not separate formulas to memorize from scratch.
- A few definitions get reused in every proof below.
- The fitted value is .
- The residual is the leftover gap: .
- The two normal equations are and — recall from the fitting derivation that these come directly from setting the two partial derivatives of SSE equal to zero.
- Proof 1 proves — the residuals sum to exactly zero.
- Start from the definition of the residual: .
- Sum this over every observation: .
- The first normal equation says — substitute that in.
- The right-hand side becomes .
- This proof is really just the first normal equation, read backwards: differentiating SSE with respect to and setting it to zero is the statement .
- In plain terms: positive and negative residuals exactly balance out once you’ve fit an intercept, so the average residual is zero.
- Proof 2 proves — the residuals, each weighted by its own , also sum to zero.
- Multiply the residual definition by and sum: .
- The second normal equation says — substitute that in, and the sum is .
- An alternative route that exposes directly: substitute and into the expansion instead, group terms into , then substitute to get .
- Proof 3 proves — the residuals are also orthogonal to the fitted values themselves, not just to the raw ‘s.
- Write and multiply by : .
- Both of those sums are already known to be , from Proofs 1 and 2 — so the whole thing is .
- This proof is “free” once you have Proofs 1 and 2: is nothing but a combination of the constant and , and the residual is already orthogonal to both of those pieces individually.
- Put together, the three proofs say the residual vector is orthogonal to the intercept column, to the predictor column, and therefore to the fitted values.
- Geometrically: least squares splits the observed response into a fitted piece that lives in the “model space,” and a residual piece that is perpendicular to it.
- Before Proof 4, three sum-of-squares quantities need defining — each one is a sum of squared gaps, just measured from a different reference point.
- is the total variation: how far each sits from the overall mean .
- is the explained variation: how far the model’s fitted values sit from . Some sources call this .
- is the unexplained variation: the leftover residuals, squared. Some sources call this .
- Naming warning: textbooks disagree on whether “SSR” means regression or residual — rely on the formula itself, not the three letters.
- Proof 4 shows these three quantities fit together exactly: .
- Step 1 splits each observation’s total deviation into two pieces, by inserting and subtracting the fitted value : .
- This rewrites “total deviation” as “unexplained deviation plus explained deviation.”
- It’s the same telescoping trick used elsewhere in the course: insert and subtract a middle quantity so one unfamiliar gap becomes two gaps you already have names for.
- Step 2 squares both sides of that split: .
- Step 3 sums that equation over every observation: .
- Step 4 shows the middle “cross term” is exactly zero.
- Expand it: .
- The first piece is by Proof 3, and the second is by Proof 1.
- So the cross term vanishes entirely.
- This step is the whole payoff of Proofs 1–3 — they exist specifically so this cross term dies, which is what makes an exact equality rather than an approximation.
- Step 5 drops the now-zero cross term to conclude: .
- This works cleanly because least squares made the residuals orthogonal to the fitted values (Proof 3) — a model that wasn’t fit by least squares wouldn’t get this identity for free.
- Step 1 splits each observation’s total deviation into two pieces, by inserting and subtracting the fitted value : .
Practice Problems
-
Problem 1 (HW1 Q1). Prove and using the normal equations. Write it the way you would on the exam — the Concepts section above has the fully justified version; this is the fast, exam-pace version of the same two proofs.
- Solution.
- :
- first normal equation:
- :
- second normal equation:
- :
- Solution.
-
Problem 2 (HW1 Q3). Prove . Same exam-pace instruction as above.
- Solution.
- square both sides:
- sum over :
- cross term: (using and )
- Solution.
-
Problem 3 — numeric verification (class data). Using the fitted line from the class dataset , compute all five residuals and verify both residual identities and the decomposition numerically.
- Solution.
- residuals: : ; : ; : ; : ; :
- check
- check
- , so
- check: ✓
- Solution.