StatGardenREF. DESK
Calculators/Statistics/Residual Calculator
Statistics

Residual Calculator calculator

Residuals (observed minus predicted) for a data set against its least-squares regression line.

Published 21 August 2026

What this calculator does

A residual is the difference between an observed value and the value a model predicted for it: residual = observed y − predicted y. In simple linear regression, the predicted value comes from the least-squares line of best fit, so a residual is really a measure of how far each individual data point sits from that line, above or below it.

This residual calculator takes a set of x and y values, fits the least-squares line the same way the correlation and linear regression calculator does, and then reports the residual for every point along with summary figures such as the mean absolute residual and the sum of squared residuals. It answers how to calculate residual for a whole data set at once, rather than one point at a time by hand.

The formula

FormulaResidual = observed y − predicted y; predicted y = a + b·x, from the least-squares line of best fit

The line of best fit is found first, giving a slope and an intercept. For each x value, the predicted y is intercept plus slope times x. Subtracting that predicted value from the actual observed y gives the residual for that point; a positive residual means the actual point sits above the line, a negative one means it sits below.

TermMeaning
ResidualObserved y minus predicted y for a single data point; positive means above the regression line, negative means below it.
Predicted yThe y value the regression line gives for a particular x, calculated as intercept + slope × x.
Sum of squared residuals (SSE)Every residual squared and added together; the quantity the least-squares line is built to minimise.
Line of best fitThe straight line through the data that minimises the sum of squared residuals, defined by its slope and intercept.

The inputs explained

FieldWhat to enter
X valuesThe x values, separated by commas or spaces, in the same order as the matching y values below.
Y valuesThe y values (the observed, actual results), in the same order as the x values above.

When to use it

Checking how well a regression line fits

Small, evenly scattered residuals suggest the straight line is a reasonable description of the data; large or lopsided residuals suggest it is not, or that the relationship is not really linear.

Spotting an outlier in a data set

A point with a residual much larger than the others is sitting well away from the trend the rest of the data follows, worth checking for a measurement error before treating it as a genuine result.

Working residual formula problems by hand

Entering the same x and y values used in a textbook question and comparing them against the per-point residual formula and equation shown checks a hand calculation before submitting it.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How residuals grow as the same data set gets noisier

The same x values, 1 through 8, paired with a perfectly linear y set, a slightly noisy one, and one containing a single large outlier.

Fixed x values, three y data sets of increasing scatter
Y data setMean absolute residualSum of squared residuals (SSE)Largest residual (by magnitude)
Perfectly linear000 at x = 1.000
Slightly noisy0.11520.1639-0.2821 at x = 4.000
One large outlier2.558120.57310.233 at x = 4.000
A perfectly linear data set has every residual equal to zero. Adding realistic noise lifts the mean absolute residual to about 0.115 and the SSE to about 0.164, but replacing just one point with a clear outlier (20 instead of about 7.9 at x = 4) drags the SSE up to over 120 and the largest single residual past 10, showing how sensitive squared residuals are to a single bad point.

Questions

What is the residual formula?

Residual = observed y − predicted y, where predicted y comes from the regression line (intercept + slope × x) fitted to the data.

How to find residual for a specific point?

Work out what the regression line predicts at that point’s x value, then subtract that prediction from the point’s actual y value. This calculator does that for every point in the data set entered.

Why are some residuals negative?

A negative residual simply means the observed point sits below the regression line at that x value; a positive residual means it sits above. The sign is not an error, it is direction.

What is a large residual telling me?

A residual that is much bigger than the others suggests that point does not follow the trend the rest of the data does, which can mean measurement error, a genuine unusual case, or that a straight line is not the right shape for the relationship.

For the correlation coefficient and the regression line itself, see the correlation and linear regression calculator. For fitting a curve through points a different way, see the trapezoidal rule calculator.