Building a line in three moves
A least-squares line is fitted, not guessed, and it arrives in three moves. First the slope: — b equals r, times s-y over s-x. The subscripts name the variable, not an order: is the standard deviation of , the response you are predicting, and that of , the predictor you are predicting from. is the correlation coefficient, a naked number between −1 and 1, and is the slope in response-units per predictor-unit. Read the ratio as a converter: it turns one unit of into the matching amount of , and discounts it for the fit being imperfect.
Second the intercept: — a equals y-bar minus b x-bar, where and (say x-bar, y-bar) are the two means, and is the line's height at . This one is free, and here is why: every least-squares line passes through , the point of averages. Stand at that point and walk back down the slope to ; where you land is . Third, the prediction: — y-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 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.