Lesson
The theory — Least-Squares Geometry Explorer
“Least squares” names what is being minimised: the sum of squared residuals. Geometrically the fitted values are the closest point to your data within the set of curves the model can produce — closest in the ordinary straight-line sense, which is why the leftover residual vector ends up perpendicular to everything the model could have done.
What each symbol means
residual- one gap between a data point and the fitted curve, measured vertically. The readout lists every one before squaring it.
SSE- the sum of squared errors — add up the squares of all the residuals.
1.3714for the straight-line fit here. RMSE- the root mean square error,
√(SSE/n) = 0.4781. Unlike SSE it is in the same units as y, so it is the one worth quoting. model- the family of curves allowed. Switching from line to quadratic widens that family from two free numbers to three.
Where the formula comes from
- Each candidate curve produces a list of fitted values. Treat that list as a single point in n-dimensional space, and treat your data as another point there.
- SSE is then literally the squared distance between those two points. Minimising SSE means finding the reachable point closest to the data — a projection, not a search.
- And the defining property of a projection is that the error is perpendicular to everything reachable. That is why the residuals of a best fit always sum to zero and show no leftover correlation with x: any such pattern would be a direction the model could still have moved in.
How to read what you see
The point count, then the fitted model written out, then SSE shown term by term — −0.7143² + 0.3714² + 0.4571² + ⋯ = 1.3714 — so you can see which point is hurting the fit before the squares hide the signs. RMSE comes last as the human-readable summary.
- Assumes
- Vertical gaps only, so x is treated as exact, and every point weighted equally. The model must also be linear in its parameters — which a quadratic still is, despite the curve, because
x²enters multiplied by a constant. - Breaks when
- A smaller SSE does not mean a better model, and you can prove it here in one click. Switch from line to quadratic and SSE falls from
1.3714to0.4071— it was always going to fall, because a quadratic contains every straight line as the special case where thex²coefficient is zero. A model with more freedom cannot fit worse, so SSE alone can never tell you whether the extra term is real or is fitting noise.
Practice
Check yourself
Predict the answer first, then use the controls above to find out. Reveal only after you have committed to a guess — that is what makes it practice.
-
Press braking with line: six points, a straight fit, SSE
84. Now press braking with curve — the same six points, fitted with a quadratic. Predict the new SSE.Show answer
0. Not nearly zero: zero, with RMSE0and a fitted curve ofŷ = 8 − 0.25x + 0.015x². Those six points came off that parabola exactly, and once the family of allowed curves contains the truth there is nothing left over to square. A falling SSE on its own proves nothing — a wider family can never fit worse. A fall all the way to the floor is different in kind, because there is no residual left for any further model to remove. -
Press course retention, which fits a line with SSE
1.3714and a largest-point SSE share of37.2%. Switch the model selector to Quadratic. SSE will fall — predict what the largest-point share does.Show answer
It goes up, to56.3%, while SSE falls to0.4071. A share is not an amount: the extra freedom pulled the curve towards the points it could reach, so the one it still cannot reach now makes up a bigger fraction of a smaller total. One warning while you are here — pressing any preset snaps the selector back to Line, so these numbers only mean this while Quadratic is still showing. -
Back to braking with line. The readout shows five of the six residuals before its
⋯:5,−1,−4,−4,−1. What is the sixth, and what do the six together tell you that SSE84does not?Show answer
+5. The residuals of a least-squares fit always sum to zero and the five shown add to−5, so the missing one is forced. The residual plot draws exactly that shape: two tall bars up at the ends, four dipping below through the middle, a clean U. Summing to zero and leaving no tilt against x is the whole of what least squares guarantees, and a symmetric U satisfies both — its residuals really do sum to zero, and it leans neither way — so a straight line can neither absorb it nor notice it. SSE says the fit is loose; only the pattern says it is loose in one direction at a time.
Problem solved in full
-
Six points with a sum of squared errors of 1.3714 5 steps
Six points, a fitted line, and a sum of squared errors of 1.3714. Work out how much of that total comes from a single point — and prove a fact about the residuals that holds for every least-squares fit ever computed.
-
The coefficients come from the same two sums as any simple regression: how x and y vary together, over how x varies alone.
-
That gives the line the panel reports. Nothing about this data is special — it is a nearly straight run of six points with a little scatter.
-
The residuals are what the fit could not explain. Compute all six and one of them is conspicuous: the point at x = 0 is off by −0.7143, roughly double the typical miss.
-
Before using them, notice they sum to zero — not approximately, exactly. That is forced by the intercept: the second normal equation is the statement that the residuals average to zero, so it is true of every least-squares line regardless of the data.
-
Squaring destroys that balance, and that is the point. The −0.7143 becomes 0.5102, which is 37.2% of the total SSE of 1.3714 — one point in six carrying more than a third of the penalty.
Answer
The tool prints SSE = 1.3714, RMSE = 0.4781 and a largest-point share of 37.2%. Both facts matter and they pull against each other. The residuals summing to zero says the line is balanced; the 37.2% says the fit is not, because squaring weights a double-sized miss four times as heavily. That is exactly why least squares is so sensitive to outliers, and why the residuals-sum-to-zero property is no protection at all: a single bad point cannot shift the average residual, and can still dominate what the line is trying to minimise.
-
Learning path
Fitting a line to data
References (1)
- Least squares as an orthogonal projection, which is what makes the residuals perpendicular to the model: G. Strang, Introduction to Linear Algebra, 5th ed., chapter 4 (“Orthogonality”). Wellesley-Cambridge Press, 2016. ISBN 978-0-9802327-7-6.