Memra

The least-squares line

◈ 5 cards

Minimise Σe²; the slope from SP_xy / SS_xx and the intercept from the means; three equivalent slope forms and the rounding trap.

The line that makes the errors smallest

Many lines pass near the eight points. The least-squares line is the one that minimises the sum of the squared vertical gaps

Vertical, because is the response being predicted; squared, so that positive and negative misses do not cancel and large misses are penalised. The minimising slope and intercept have closed forms:

where and — the two numerators you already built in L4.1 and L4.2. The intercept formula says the line always passes through the point of means .

Worked example — fitting Northfield's line

.

.

Three forms of the same slope

Because and , the slope can be written three ways, and the paper may hand you the inputs for any of them:

Check: ; . Same line.

The rounding trap

The third form is where marks go missing. Use (three decimals) and the slope comes out ; use and it is — off in the second decimal. The intercept then inherits the error multiplied by . Carry and the SDs to at least four decimals until the final line, or — better — take the slope from , where every input is an exact sum.

What the fit cannot tell you

Least squares always produces a line, for any cloud of points, however curved or however dominated by one point. That the arithmetic ran is not evidence that a line is the right description; the scatter plot and have to have earned it first.

FormInputsArithmeticSlopeSP_xy / SS_xxSP_xy = 9,362.5 ·SS_xx = 4,531.8759,362.5 / 4,531.8752.0659s_xy / s_x²s_xy = 1,337.5 ·s_x² = 647.411,337.5 / 647.412.0659r · s_y / s_xr = 0.98589 · s_y =53.319 · s_x =25.4440.98589 × 53.319 /25.4442.0659r rounded to 0.99r = 0.990.99 × 53.319 /25.4442.0745Intercept: β̂₀ = ȳ − β̂₁·x̄ = 687.5 − 2.0659 × 69.375 = 544.18.
Three routes to one slope. The first uses exact sums and is the one to prefer by hand; the third is the one that suffers when r is rounded early.
NORMAL ~/memra/learn/afm-113/the-least-squares-line utf-8 LF