Week 5 · Using the regression line: predicting y, the error of a prediction, extrapolation and regression from given sums · 3 lessons
1
A full worked regression: the sums, b and a, the line, a prediction and the error at a known point
Statistics Sec 3 Term 1, Unit 1, Lesson 2
GoalCarry out a complete regression: the sums, b and a, the line, a prediction and the error at a known point.
New words
prediction · the value of ŷ that the line gives for a chosen xerror of a prediction · |observed y − ŷ| at a known pointinterpolation · predicting for an x inside the range of the data
Explanation
A farm records, for eight date palms, the irrigation water per month x (in cubic metres) and the dates harvested y (in kg). The five sums are in the table: n = 8, Σx = 43, Σy = 290, Σxy = 1777, Σx² = 277. First b = (nΣxy − Σx·Σy) ÷ (nΣx² − (Σx)²) = (8 × 1777 − 43 × 290) ÷ (8 × 277 − 43²) = 1746 ÷ 367 = 4.7575. Then a = (Σy − bΣx) ÷ n = (290 − 4.7575 × 43) ÷ 8 = 10.678. The regression line of y on x is ŷ = 10.678 + 4.7575x: each extra cubic metre of water adds about 4.76 kg of dates. To predict, replace x in the line. To find the error at a point we already know, subtract: error = |observed y − ŷ|. Keep the unrounded b in your calculator while you work, and round only the final answer; this is why two people may differ in the last decimal. The picture shows the eight dots and the line.
Water x (m³)
Dates y (kg)
xy
x²
y²
2
21
42
4
441
3
26
78
9
676
3
24
72
9
576
5
35
175
25
1225
6
36
216
36
1296
7
47
329
49
2209
8
44
352
64
1936
9
57
513
81
3249
Σx = 43
Σy = 290
Σxy = 1777
Σx² = 277
Σy² = 11608
Worked examples
Prediction inside the range. With 4 m³ of water: ŷ = 10.678 + 4.7575 × 4 = 29.71 kg. The values of x in the data run from 2 to 9, and 4 is inside this range, so the prediction is reliable.
Error at a known point. The palm with x = 7 m³ gave y = 47 kg. The line gives ŷ = 10.678 + 4.7575 × 7 = 43.98 kg, so the error is |47 − 43.98| = 3.02 kg. The dot is above the line.
A check. The means are x̄ = 43 ÷ 8 = 5.375 and ȳ = 290 ÷ 8 = 36.25, and the line at x̄ gives 10.678 + 4.7575 × 5.375 = 36.25: it passes through (x̄, ȳ), so b and a are probably right. The sign of b is positive, like the sign of r (which is 0.9736).
Class activity
Using the line ŷ = 10.678 + 4.7575x find the predicted harvest for 3 m³ and for 8 m³ of water. Then compare the 8 m³ prediction with the real palm in the table that received 8 m³ (44 kg) and give the error.
Practice
1
Predict the harvest for 5 m³ of water with the line ŷ = 10.678 + 4.7575x.
ŷ = 10.678 + 23.7875 = 34.47 kg (rounded to 2 decimals).
2
The palm that got 8 m³ gave 44 kg. Find ŷ and the error.
ŷ = 10.678 + 38.06 = 48.74 kg. Error |44 − 48.74| = 4.74 kg; the dot is below the line.
3
What does b = 4.7575 mean in this story?
For each extra cubic metre of water per month the predicted harvest rises by about 4.76 kg.
4
The line is ŷ = 10.678 + 4.7575x. Why can a palm that received 0 m³ of water not be predicted with it?
The data start at 2 m³. x = 0 lies outside the range, so ŷ = 10.678 kg would be an unreliable guess.
5
The two palms with x = 3 gave 26 and 24 kg. Find ŷ at x = 3 and both errors.
ŷ = 10.678 + 14.2725 = 24.95 kg. Errors |26 − 24.95| = 1.05 and |24 − 24.95| = 0.95.