Least-squares line
📐FORMULA
$$\hat{y} = a + b,x \qquad b = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sum (x_i - \bar{x})^{2}} \qquad a = \bar{y} - b,\bar{x}$$
- b: the slope, the average change in y for one more unit of x
- a: the intercept, the predicted y when x is zero (often a value nobody has ever observed)
- x̄, ȳ: the two means; the line always passes through the point (x̄, ȳ)
The same slope can be written b = r × s_y / s_x, the correlation times the ratio of the two standard deviations. Least squares means this is the line that makes the sum of squared vertical misses as small as it can be.
Worked number. Five points I keep for checking my hand arithmetic: x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5. Means 3 and 4. The top sum is 6, the bottom sum is 10, so b = 0.6 and a = 4 − 0.6 × 3 = 2.2.
What the slope does not mean
- It does not say that changing x by one will move y by b. It describes the units I have, not what would happen if I intervened.
- It says nothing outside the range of x I observed.
- It is an average. Individual points sit above and below it, sometimes a long way.
From 🎓 Lecture 12 - Fitting a line. Explaining exactly this to a non-statistician was the brief of 📌 Statistics II - Assignment 3 - A regression you can explain, written with a cold and marked accordingly.