Fit a line by least squares
State what least squares minimises and why the deviations are squared. The idea in plain words, a worked example, and a check with the answers shown — part of the free Statistics guides.
Every straight line through a scatter leaves a vertical gap at each point: the observation's minus the line's height there. Least squares chooses the line whose gaps, squared and added, are as small as possible:
Squared so that a gap above and a gap below cannot cancel, and so that a point twice as far away counts four times as much. Vertical because the model predicts from.
Setting the two partial derivatives to zero gives the normal equations, and their solutions are
where and.
The intercept is not chosen independently of the slope. Once is known, the line is rotated about the point of the means, and is what keeps it passing through that point.
That has a practical consequence worth remembering: the intercept is only meaningful when is inside, or near, the observed range. A fitted intercept of from data whose runs from to is the line's height at a nobody measured, and reporting it as "the value when is zero" is an extrapolation wearing a parameter's name.
Data: and.
The means. and.
The slope., and, so.
The intercept..
So the fitted line is — and here it happens to pass through every point, which is what a perfect line looks like. Check: the residuals are all zero, and they sum to zero as they must.
- State what least squares minimises and why the deviations are squared
- Compute the slope and intercept from a data table
- Explain why the line passes through the point of the means
- Say when a fitted intercept is meaningful
- 1. For and, compute.
- 2. Compute and write the line.
- 3. What is the fitted value at?
- 4. Do the residuals sum to zero?
Answers
1.,;,, so. 2., so. 3.. 4. Yes — that is the first normal equation, and it holds for any least-squares fit with an intercept.