🧮
🧮 Math & statistics

Residual Calculator (residuals e = y − ŷ, sum of squares, largest residual)

Results update as you type.

Your numbers

Understanding the residual calculator — concept and principle

This calculator finds the residuals of a straight-line fit: how far each observed y value lies above or below the line. It fits the least-squares line for you or uses a line you supply, and reports each residual, their sum, the sum of squares, the largest residual and the residual standard error. Use it for statistics homework, checking a regression, and spotting outliers or curvature.

Residuals from a least-squares lineResidual = point − lineŷ = 1.966x + 1.12residuals e = y − ŷ (enlarged)+0.01−0.15+0.18−0.18+0.35−0.21Σe² · Σe0.259429 · 0
The residuals, enlarged here, go up and down and cancel; their squares add to 0.2594.

How it is calculated

The principle

A residual is the part of each observation the line does not explain. Least squares chooses the line that makes the sum of squared residuals as small as possible; squaring treats points above and below alike and penalises big misses more. One consequence is that least-squares residuals always add up to zero, and the line passes through the point (x̄, ȳ). Dividing SSE by n − 2 instead of n accounts for the two numbers, slope and intercept, estimated from the same data.

Worked example

Default data: x = 1 to 6, y = 3.1, 4.9, 7.2, 8.8, 11.3, 12.7; least-squares line.

  1. x̄ = 3.5, ȳ = 8; Σ(x − x̄)(y − ȳ) = 34.4 and Σ(x − x̄)² = 17.5.
  2. m = 34.4 ÷ 17.5 ≈ 1.96571; b = 8 − 1.96571 × 3.5 = 1.12. Line: ŷ = 1.96571x + 1.12.
  3. Residuals: 0.0142857, −0.151429, 0.182857, −0.182857, 0.351429, −0.214286; their sum is 0.
  4. SSE = 0.259429.
  5. Largest residual: 0.351429 at point 5. Residual standard error = √(0.259429 ÷ 4) ≈ 0.254671.

How to read the result

Small residuals relative to the y values mean a good fit. The residual standard error is the typical size of a miss, in y units. Look at the pattern: residuals that alternate randomly in sign, as here, suggest a straight line is fine; a curve shape, a funnel shape or one residual much larger than the rest point to a curved relationship, changing variance or an outlier.

Common mistakes

Keep in mind: Residuals check the shape of the relationship, not whether one variable causes the other. With very few points, patterns are hard to judge.

Frequently asked questions

What does a positive residual mean?

The observed value is above the line; the model underestimated it.

Why do least-squares residuals sum to zero?

Because the fitted intercept places the line through (x̄, ȳ), balancing positive and negative misses.

What is a residual plot?

A graph of residuals against x or ŷ, used to spot curvature, changing spread and outliers.

Sources: NIST/SEMATECH e-Handbook of Statistical Methods, §4.1.4.1 Linear Least Squares Regression

Checked 9 Nov 2026. NIST/SEMATECH e-Handbook of Statistical Methods, §4.1.4.1 Linear Least Squares Regression (least-squares estimates minimise the sum of squared deviations between data and model). Residual e = y − ŷ, least-squares slope and intercept and residual standard error: standard formulas.

🧮 All math & statistics tools →🌍 Calculators by country →