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
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.
| Term | Meaning |
|---|---|
| Residual | Observed y minus predicted y for a single data point; positive means above the regression line, negative means below it. |
| Predicted y | The 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 fit | The straight line through the data that minimises the sum of squared residuals, defined by its slope and intercept. |
The inputs explained
| Field | What to enter |
|---|---|
| X values | The x values, separated by commas or spaces, in the same order as the matching y values below. |
| Y values | The 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.
| Y data set | Mean absolute residual | Sum of squared residuals (SSE) | Largest residual (by magnitude) |
|---|---|---|---|
| Perfectly linear | 0 | 0 | 0 at x = 1.000 |
| Slightly noisy | 0.1152 | 0.1639 | -0.2821 at x = 4.000 |
| One large outlier | 2.558 | 120.573 | 10.233 at x = 4.000 |
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.