☰ خطة العام · الإحصاء (بالإنجليزية)

Regression and the least squares line

الأسبوع 4 · الانحدار: التنبؤ بالمتغير ⁦y⁩ من ⁦x⁩، والانحدار الخطي البسيط ⁦y = a + bx⁩ وطريقة المربعات الصغرى · 3 دروس
3

The formulas for b and a from the two normal equations, and writing the regression line from a small table

Statistics Sec 3 Term 1, Unit 1, Lesson 2
GoalFind b and a from the normal equations or the formulas, and write the regression line from a small table.
New words
normal equations · Σy = na + bΣx and Σxy = aΣx + bΣx², the result of least squaresb (slope) · the regression coefficient of y on x: the change of ŷ for one more unit of xa (intercept) · the value of ŷ at x = 0
Explanation

The least squares line ŷ = a + bx is given by two equations, the normal equations: Σy = na + bΣx and Σxy = aΣx + bΣx². We take them as the result of the least squares idea and solve them for the two unknowns a and b. From the first, a = (Σy − bΣx) ÷ n. Put this into the second and multiply by n: nΣxy = ΣxΣy − b(Σx)² + b·nΣx², so b = (nΣxy − Σx·Σy) ÷ (nΣx² − (Σx)²). The top of b is the numerator of Pearson’s r, and the bottom is positive, so b and r always have the same sign. Dividing the first normal equation by n gives ȳ = a + b·x̄: the regression line always passes through the point of the two means (x̄, ȳ), which is a good check. For the throw data: Σx = 35, Σy = 60, Σxy = 472, Σx² = 285, n = 5. Then b = (5 × 472 − 35 × 60) ÷ (5 × 285 − 35²) = 260 ÷ 200 = 1.3 and a = (60 − 1.3 × 35) ÷ 5 = 2.9. The line is ŷ = 2.9 + 1.3x: each extra week of training adds about 1.3 m to the predicted throw.

Weeks xThrow y (m)xyx²y²
3824964
58402564
7117749121
91614481256
1117187121289
Σx = 35Σy = 60Σxy = 472Σx² = 285Σy² = 794
Worked examples
By elimination. The normal equations are 60 = 5a + 35b and 472 = 35a + 285b. Multiply the first by 7: 420 = 35a + 245b. Subtract it from the second: 52 = 40b, so b = 1.3. Then 5a = 60 − 45.5 = 14.5, so a = 2.9.
Checks and use. The means are x̄ = 35 ÷ 5 = 7 and ȳ = 60 ÷ 5 = 12, and 2.9 + 1.3 × 7 = 12, so the line passes through (7, 12). A pupil trained 8 weeks: ŷ = 2.9 + 1.3 × 8 = 13.3 m. At x = 9 the pupil threw 16 m and the line gives 14.6 m, so the error |16 − 14.6| is 1.4 m.
Meaning of a and b. b = 1.3 m per week is the slope: it carries the units “metres per week”, unlike r, which has no unit. a = 2.9 m is the value of the line at x = 0 weeks; it need not be a real throw, because x = 0 is outside the weeks we measured (3 to 11).
Class activity

Take the four pairs (1, 2), (2, 3), (3, 3), (4, 5). Find the sums, then b and a, then check that your line passes through the point of the means. Draw the dots and the line on squared paper. (Answer: ŷ = 1 + 0.9x.)

Practice
1
For the pairs (1, 4), (2, 4), (3, 6), (4, 8) find the regression line of y on x.
2
Check that this line passes through the point of the means, and predict y at x = 5.
3
Used motorbikes: age x = 1, 3, 5, 9, 12 years and price y = 18, 13, 13, 10, 8 thousand LE. Find the line.
4
What does b = −0.8 mean for the motorbikes?
5
The means of a data set are x̄ = 6 and ȳ = 20, and b = 3. Find a.