AP® Statistics · Unit 5 · Topic 5.5
Where the Least-Squares Line Comes From
The least-squares line is the one line that makes the sum of squared residuals as small as possible, and its slope and intercept can be calculated directly from the means, standard deviations, and correlation of the two variables.
Imagine sliding a line up, down, and tilting it through a scatterplot, checking the vertical misses, the residuals, at every position. You want the line that is overall closest to every point. If you just added up the residuals, positive and negative ones would cancel out, so a terrible line could show a sum near zero by accident, some points wildly above, some wildly below, averaging out. Squaring each residual before adding fixes that: every miss becomes a positive penalty, big misses count a lot more than small ones, and there's exactly one line that makes this total as small as possible.
That line has a clean formula. Its slope is b = r times (SD of y / SD of x), and it passes through the point of averages, (mean of x, mean of y), which pins down the intercept. As you tilt a candidate line away from this exact slope, the squared residuals on one side grow faster than they shrink on the other, so the sum of squares always increases. That's the mechanism behind calling it 'least squares': any other line, even one that happens to pass through more individual points, gives a larger total of squared misses.
This formula is also why correlation and slope are linked but not the same number: r measures strength and direction only, while b rescales that relationship into the actual units of x and y. Later, when you check whether a line was the right model at all, you'll look at the residual plot built from these same squared-minimizing residuals.
Key terms
- residual
- The vertical distance between an actual y value and the y predicted by the line, actual minus predicted.
- least-squares line
- The unique line that minimizes the sum of all squared residuals for a given data set.
- slope formula
- b = r times (SD of y divided by SD of x), linking correlation to the line's steepness in real units.
- point of averages
- The point (mean of x, mean of y), which the least-squares line always passes through.
Watch it explained
- How it worksWalk me through squares growing and shrinking as a line gets dragged into position.
- Worked exampleFind the least-squares line for x with mean 10 SD 4, y with mean 25 SD 6, and r = 0.7.
- Common mistakeWhy isn't the least-squares line the one passing through the most points?
- Going furtherWhat happens to the sum of squared residuals when the line is tilted slightly?
Check yourself
End of topic.