Residual Calculator

Residual Calculator

Find how far each point sits from a best-fit line, with every residual listed and a residual plot to spot curves and outliers, or work out a single residual from an observed and predicted value.

residual = observed − predicted

Enter paired X and Y values

What is a Residual?

A residual is the gap between an observed value and the value a model predicted for it. A positive residual means the point sits above the line (the model under-predicted); a negative one means it sits below.

For a least-squares line the residuals always add up to zero, and the line is placed to make the sum of their squares as small as possible. Their size tells you how well the model fits individual points.

Their pattern matters even more. Plotted against the fitted values, good residuals look like a random band around zero. A curve, a funnel shape or a lone point far from the rest each signal a problem with the model.

Residual Formula

As defined in OpenStax Introductory Statistics, section 12.3, and the NIST/SEMATECH e-Handbook, section 4.4.4. See Sources.

1. Fit the line

b₁ = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)² · b₀ = ȳ − b₁x̄

2. Predict and subtract

ŷ = b₀ + b₁x · e = y − ŷ

3. Check the totals

Σe = 0 · SSE = Σe² is the smallest possible for any straight line

Worked Example: Flat Prices Against Floor Area

Given:
Six flats: floor area (m²) 50, 65, 80, 95, 110, 125 and price (£000) 180, 210, 245, 250, 300, 330.
Step 1:
Best-fit line:
price = 81.67 + 1.9524 × area
Step 2:
Prediction for the 95 m² flat:
ŷ = 267.1
Step 3:
Residual:
250 − 267.1 = -17.1
Result:
The 95 m² flat sits about £17,143 below the line

It's the cheapest flat for its size, so either a bargain or missing something the line can't see, such as a busy road or no garden.

Every Residual for the Flat Prices

The residuals add to zero, and their squares add to the smallest possible total.

Residuals for the worked example
AreaPricePredictedResidualSquared
50180179.30.70.5
65210208.61.42
80245237.97.151
95250267.1-17.1293.9
110300296.43.612.8
125330325.74.318.4

Common Residual Mistakes

  • Subtracting the wrong way round. Residual = observed − predicted. Reversing it flips every sign.
  • Only looking at R². A high R² can hide a curved residual pattern that says a straight line is the wrong model.
  • Deleting points with big residuals. A large residual is a prompt to investigate, not proof of an error.
  • Ignoring a funnel shape. Residuals that spread out as predictions grow mean the error isn't constant. Try a log scale.

Residual FAQs

What does a positive residual mean?

The actual value is higher than predicted: the point sits above the line.

Why do residuals add up to zero?

A least-squares line with an intercept always passes through the point (x̄, ȳ), which balances the positive and negative residuals exactly.

What should a good residual plot look like?

A shapeless horizontal band around zero, with no curve, no funnel and no isolated points.

What is a standardised residual?

A residual divided by its estimated standard deviation. Values beyond about ±2 are worth a look.

What is the difference between a residual and an error?

The error is the gap from the true (unknown) line; the residual is the gap from the fitted line. Residuals are our estimates of the errors.

How do residuals give R²?

R² = 1 − (sum of squared residuals) ÷ (total sum of squares around the mean).

How do I get residuals in Excel?

Use the Data Analysis ToolPak’s Regression tool and tick “Residuals”, or subtract =FORECAST.LINEAR predictions from the actual values.

Can I get residuals for a curve?

Yes, the formula is the same: observed minus the curve’s prediction. The polynomial and exponential regression calculators fit curves.

Sources

Related Tools