Phase 1: Prepare
Step 1 Warm-up recall
From M3.L2: what does the fitted line pass through?
Private: nothing you type here is sent or stored.
Step 2 Learning goal
By the end of this lesson you can:
- calculate residuals (Foundation);
- compute R squared by hand (Core);
- read R squared against the baseline (Core).
Phase 2: Teach
Step 3 A familiar example
A manager is shown a line that predicts weekly sales from advertising spend. She asks how much better it is than just quoting the average. R squared answers that question.
Step 4 Clear explanation
A residual is the actual value minus the line's prediction. (Module 2 used predicted minus actual; many regression texts use the opposite, so state which you use.) For the revision line y = 2.2 + 0.6x:
| Hours x | Actual y | Predicted 2.2 + 0.6x | Residual (actual − predicted) | Squared |
|---|---|---|---|---|
| 1 | 2 | 2.8 | −0.8 | 0.64 |
| 2 | 4 | 3.4 | +0.6 | 0.36 |
| 3 | 5 | 4.0 | +1.0 | 1.00 |
| 4 | 4 | 4.6 | −0.6 | 0.36 |
| 5 | 5 | 5.2 | −0.2 | 0.04 |
| total | 0.0 | 2.40 |
Residuals from a least-squares line always add to zero, which is another check. The total squared residual is 2.4. The baseline of always predicting the mean (4) has errors −2, 0, 1, 0 and 1, whose squares total 6.
R squared = 1 − (line's squared error ÷ baseline's squared error) = 1 − 2.4 ÷ 6 = 0.6. It is the share of the baseline's squared error that the line removes: 60 percent here. It is the same idea as improvement over a baseline from Module 2.
Two cautions. A high R squared does not prove cause, and on a handful of points it can be high by chance. Always look at the residuals as well: a pattern in them, such as all positive in the middle and negative at the ends, shows that a straight line is the wrong shape.
Step 5 Worked example (4 marks)
A line leaves a total squared error of 5. The mean baseline leaves 20. Find R squared and interpret it.
- Ratio = 5 ÷ 20 = 0.25. (1 mark)
- R squared = 1 − 0.25 = 0.75. (1 mark)
- It is the share of baseline error removed. (1 mark)
- Answer: 0.75; the line removes 75 percent of the baseline's squared error. (1 mark)
Go deeper: the professor's notes
Actual minus predicted.
Total of squares.
Compare with baseline.
Fit
| Line error | Baseline error | R squared |
|---|---|---|
| 2.4 | 6 | 0.60 |
| 5 | 20 | 0.75 |
At work: A fitted line
The line leaves 2.4 and the mean leaves 6.
- Compute 1 minus 2.4 over 6.
- Inspect residuals for a pattern.
What a careful practitioner decides. A good R squared still needs a plot and unseen data.
Phase 3: Practise
Step 6 Learner practice (instant-marked)
1. A residual here is:
The leftover gap.
2. Residuals from a least-squares line add to:
They cancel exactly.
3. Line error 3, baseline error 12. R squared is:
1 − 3 ÷ 12.
4. A pattern in the residuals suggests:
Systematic misfit.
Phase 4: Close
Step 7 Recap
- Residual = actual − predicted; they add to zero for a least-squares line.
- R squared = 1 − line error ÷ baseline error.
- Look at the residuals, not only R squared.
Step 8 Exit ticket (ungraded)
A line has squared error 8 and the baseline has 32. Find R squared.
Private: nothing you type here is sent or stored.
Step 9 Go further (Extension)
Sketch residuals against x for the table above and say whether any pattern is visible.
In industry: Galton: why the word regression
In his 1886 paper Galton used the heights of 930 adult children and of their 205 parentages. He multiplied female heights by 1.08 to put them on a male scale, and found that the deviations of the children from average were about two thirds of the deviations of their mid-parents.
Link to this lesson. Regression began as a slope of about two thirds, which is why very tall parents tend to have children closer to average.
Source: Galton (1886), Regression towards Mediocrity in Hereditary Stature, Journal of the Anthropological Institute 15; Hanley (2004), Transmuting Women into Men, The American Statistician
Common mistakes
| Mistake | Why it fails |
|---|---|
| Reading R squared as accuracy | It is the share of baseline squared error removed. |
| Ignoring the residuals | A good number can hide a poor shape. |
| Claiming cause from a high R squared | It shows fit, not cause. |
Limits. R squared on the fitting data flatters the model; Module 5 tests on unseen data.