Grade 12 Math · The line of best fit
Building a line in three moves
score 0

Building a line in three moves

A least-squares line is fitted, not guessed, and it arrives in three moves. First the slope: b=rsysxb = r\,\dfrac{s_y}{s_x}b equals r, times s-y over s-x. The subscripts name the variable, not an order: sys_y is the standard deviation of yy, the response you are predicting, and sxs_x that of xx, the predictor you are predicting from. rr is the correlation coefficient, a naked number between −1 and 1, and bb is the slope in response-units per predictor-unit. Read the ratio as a converter: it turns one unit of xx into the matching amount of yy, and rr discounts it for the fit being imperfect.

Second the intercept: a=yˉbxˉa = \bar{y} - b\bar{x}a equals y-bar minus b x-bar, where xˉ\bar{x} and yˉ\bar{y} (say x-bar, y-bar) are the two means, and aa is the line's height at x=0x = 0. This one is free, and here is why: every least-squares line passes through (xˉ,yˉ)(\bar{x}, \bar{y}), the point of averages. Stand at that point and walk back down the slope to x=0x = 0; where you land is aa. Third, the prediction: y^=a+bx\hat{y} = a + bxy-hat equals a plus b x, where the hat means predicted, not observed, and that hat matters.

One warning to carry out of this lesson. A fitted line is only evidence about the range of xx the data actually covered. Reading it far outside that range is extrapolation, and the line will answer with total confidence and no justification whatsoever — it does not know the data stopped. Fertilizer improves yield right up until it doesn't, and the line will never mention it.