Checking a zero residual sum without claiming a perfect fit
Residuals from a least-squares line with an intercept always add up to zero. That fact says nothing about how well the line fits, and this guide shows a three-point example where each prediction still misses.
Fitting the line to three points
The points are (0, 0), (1, 2) and (2, 1). The mean of x is 1 and the mean of y is 1. The slope is the sum of products of deviations divided by the sum of squared x deviations. The x deviations are -1, 0, 1 and the y deviations are -1, 1, 0, so the products add up to 1 and the squared x deviations add up to 2. The slope is 0.5. The intercept is the mean of y minus slope times mean of x, which is 1 - 0.5 = 0.5. The line is y = 0.5 + 0.5x, and the linear regression calculator returns exactly those coefficients for the inputs 0,1,2 and 0,2,1.
Predictions and residuals point by point
At x = 0 the line predicts 0.5, at x = 1 it predicts 1 and at x = 2 it predicts 1.5. A residual here is actual minus predicted: 0 - 0.5 = -0.5, then 2 - 1 = 1, then 1 - 1.5 = -0.5. Only the middle prediction matches in size, and even there the sign pattern shows the line missing the data above and below. The sum of the residuals is -0.5 + 1 - 0.5 = 0, so their mean is 0, which the average calculator confirms when you enter -0.5, 1, -0.5. A reader who sees only that mean could conclude that the line fits perfectly, and the example exists to show why that conclusion would be wrong.
Why the sum must be zero
Ordinary least squares picks the intercept and slope that minimize the sum of squared residuals. Setting the derivative with respect to the intercept to zero gives the first normal equation, which says the residuals add up to zero. This holds for every data set as long as the model includes an intercept term. In this example the second normal equation also holds: the sum of x times residual is 0 × (-0.5) + 1 × 1 + 2 × (-0.5) = 0. The residuals are therefore orthogonal to both the constant and x. Because zero total error is guaranteed by the method, it is not evidence of quality. A fit through a cloud of unrelated points still has residuals that sum to zero.
A magnitude measure that does not cancel
Root-mean-square error squares each residual before averaging, so negative and positive values cannot offset one another. The squares are 0.25, 1 and 0.25, which add up to 1.5. Divided by 3, the mean square is 0.5, and the square root is about 0.7071. The root-mean-square calculator returns 0.7071067811865476 for the list -0.5, 1, -0.5. The squaring step is also why one large residual dominates this measure: the single miss of 1 contributes two thirds of the total squared error. Residuals of that size are large against y values that range only from 0 to 2. The typical miss is about 0.71 units, compared with a total spread of 2. Mean absolute error gives another view: the absolute values 0.5, 1, 0.5 average to about 0.6667.
Putting a score next to the residuals
The coefficient of determination compares the squared error with the spread of y around its mean. The y deviations from the mean are -1, 1 and 0, giving a total sum of squares of 2. The residual sum of squares is 1.5. R squared is 1 - 1.5/2 = 0.25, so the line explains a quarter of the variation. The R squared calculator returns 0.25 for actual values 0, 2, 1 against predictions 0.5, 1, 1.5. A value of 0.25 is far from a perfect fit, even though the residual mean is exactly zero. For comparison, a perfect fit would have zero residuals and R squared 1. The two summaries differ because one is a signed total and the other is a magnitude.
Plots that would have shown it
A residual plot places the residuals on the vertical axis against x or against the fitted value. With three points it shows -0.5, then 1, then -0.5, a clear arch. An arch like that suggests curvature that a straight line does not capture, though with three points no firm conclusion about the true pattern is possible. With larger data sets, a plot with a visible curve, funnel shape or cluster of large residuals reveals problems that a zero-sum check never will. Many statistics texts recommend looking at residuals before relying on summary numbers for exactly this reason. Anscombe's 1973 quartet of four data sets, which share nearly the same fitted line and correlation yet look completely different when plotted, is the standard demonstration of how a table of summary numbers can hide the shape of the data.
Models where the sum is not zero
The zero-sum property needs the intercept. A line forced through the origin, y = bx, minimizes squared error without the intercept equation, and its residuals generally have a nonzero sum. For this data, the zero-intercept slope is the sum of xy divided by the sum of x squared, 4 divided by 5, or 0.8, and the residuals are 0, 1.2 and -0.6, which add up to 0.6. Models fitted by other criteria, such as least absolute deviations, also lack the guarantee. So a residual sum near zero is expected for ordinary least squares with an intercept and is informative only if some other method or a transformation was applied.
Residual sums in applied settings
Zero-sum residuals show up in practice as a reassuring check that is easy to misread. Spreadsheet trendline tools and statistics packages all produce residuals that sum to zero, up to rounding, whenever the fit includes an intercept. If you fit a line and find a residual sum noticeably away from zero, something is off: the fit may have no intercept, the arithmetic may have been rounded heavily, or the residuals may have been computed from a different line than the one reported. The sum is therefore a useful test of the computation. It can confirm that the numbers were produced correctly, and it cannot confirm that the model describes the data well. For that, you need magnitudes, plots and domain knowledge.
Three points and no inference
This is a descriptive demonstration with three points and no inference. It does not give a threshold for acceptable error, because an acceptable RMS depends on the units of y and the purpose of the model. It shows two things: signed residuals from this fit sum to zero by construction, and a magnitude summary such as 0.7071 or an R squared of 0.25 retains the information that the predictions miss. When you report a fit, include a measure of error size alongside the coefficients, and keep the residuals available for inspection.
Reproduce the checks
Line coefficients
Open the Linear Regression Calculator and enter:
- X observations
0,1,2- Y observations
0,2,1
Expected output:
Slope
0.5Intercept
0.5These coefficients produce the stated predictions.
Mean signed residual
Open the Average calculator and enter:
- Values
-0.5,1,-0.5
Expected output:
Arithmetic mean
0The positive and negative errors cancel.
Residual RMS
Open the Root Mean Square Calculator and enter:
- Numbers
-0.5,1,-0.5
Expected output:
Rms
0.7071067811865476A positive magnitude remains.
References and implementation scope
The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.
Sources
- Primary definition and convention reference ↗ · 2026-10-08
- NIST: Measures of location ↗ · 2026-10-08
- Primary definition and convention reference ↗ · 2026-10-08