Least-squares criterion

By Jude Wallis · Updated

The least-squares criterion picks the line that makes the sum of the squared vertical distances from the points to the line as small as possible.

Out of every line you could draw through a scatterplot, the least-squares criterion keeps the one that minimizes (yy^)2\sum (y - \hat{y})^2, where y^\hat{y} (read y-hat) is the height of the line above each xx. Two details in that sentence do the work. The distances are vertical, measured parallel to the yy axis, not perpendicular to the line, so the criterion is asking how badly the line predicts yy and nothing else. And they are squared, which stops positives and negatives cancelling and makes one big miss cost more than several small ones.

Take the four points (1,3)(1, 3), (2,4)(2, 4), (3,8)(3, 8) and (4,9)(4, 9). The obvious line through the first and last of them is y^=1+2x\hat{y} = 1 + 2x, leaving residuals 0, -1, 1 and 0, which score 0+1+1+0=20 + 1 + 1 + 0 = 2. Least squares instead returns y^=0.5+2.2x\hat{y} = 0.5 + 2.2x, whose residuals are 0.3, -0.9, 0.9 and -0.3 and score 0.09+0.81+0.81+0.09=1.80.09 + 0.81 + 0.81 + 0.09 = 1.8. No line scores below 1.8 on these four points.

What that comparison kills is the rule students reach for first: "the best line is the one whose residuals add to zero." Both lines above do that. So does every line through the point of averages (xˉ,yˉ)=(2.5,6)(\bar{x}, \bar{y}) = (2.5, 6), read x-bar and y-bar, and there are infinitely many of those. Residuals summing to zero is a property the least-squares line happens to have, not the test that identifies it.

Least squares is one criterion, not the only sensible one. Minimizing the total unsigned residual is a different rule, and on these same four points it prefers y^=1+2x\hat{y} = 1 + 2x, whose absolute total is 2.0 against the least-squares line's 2.4. Squaring is also what lets a single far-out point swing the fit, since a miss of 4 costs sixteen times a miss of 1.

The criterion is topic 5.5, Least-Squares Regression, in Unit 5 of the Fall 2026 AP Statistics course.

The deeper reason for squaring is a calculus one. A sum of squares is smooth, so its minimum sits where the derivative is zero and can be found by solving one equation, while a sum of absolute values has corners where no derivative exists and the minimum has to be hunted for. That is the same machinery as any optimization problem, and the corners are why a critical point includes places the derivative fails to exist, not just places it is zero.

More regression and correlation terms, or browse the full statistics glossary.