Residual Calculator

This residual calculator fits a regression line through your x and y values and lists every residual. Example: x = 1 to 6 and y = 2.1 to 11.6 give ŷ = 1.95143 · x + 0.153333, and the largest residual is 0.389524.

Source: Wikipedia – Errors and residuals. Updated: .

Separate with spaces or semicolons; commas also separate values, so use a decimal point (2.5), not a comma.
Separate with spaces or semicolons; commas also separate values, so use a decimal point (2.5), not a comma.
My ToolboxYour inputs are saved in this browser only.

Result

Result
Regression line ŷ = 1.95143 · x + 0.153333; largest residual 0.389524 at x = 5
Residual table
xyFitted ŷResidual e = y − ŷ
12.12.10476-0.0047619
23.94.05619-0.15619
36.26.007620.192381
47.87.95905-0.159048
510.39.910480.389524
611.611.8619-0.261905
Key figures
QuantityValue
Number of pairs n6
Slope b₁1.95143
Intercept b₀0.153333
Sum of residuals Σe0
Sum of squared residuals SSE0.307048
Residual standard error s = √(SSE / (n − 2))0.277059
Coefficient of determination R²0.995414
Calculation steps
  • Means: x̄ = 3.5, ȳ = 6.98333; Σ(x − x̄)² = 17.5, Σ(x − x̄)(y − ȳ) = 34.15.
  • b₁ = 34.15 / 17.5 = 1.95143; b₀ = 6.98333 − 1.95143 · 3.5 = 0.153333.
  • First pair: ŷ = 2.10476, residual e = 2.1 − 2.10476 = -0.0047619.
For a least-squares line the residuals sum to 0. A pattern in the residuals (a curve, a funnel) shows that a straight line does not fit or that the spread is not constant; for a curve, quadratic regression helps.

How it is calculated

A residual is what the regression line leaves over: the difference between the measured y and the predicted ŷ. Residuals show how well a straight line fits the data.

Formulas and working

First the means x̄ and ȳ are found. The slope is b₁ = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)² and the intercept b₀ = ȳ − b₁ · x̄. For every point, ŷ = b₀ + b₁ · x and the residual is e = y − ŷ. The sum of squares SSE = Σe² is divided by n − 2, and its square root is the residual standard error s. With least squares, Σe = 0 always holds.

Worked example

For x = 1, 2, 3, 4, 5, 6 and y = 2.1, 3.9, 6.2, 7.8, 10.3, 11.6, x̄ = 3.5 and ȳ = 6.98333. Σ(x − x̄)² = 17.5 and Σ(x − x̄)(y − ȳ) = 34.15, so b₁ = 34.15 / 17.5 = 1.95143 and b₀ = 0.153333. At x = 5, ŷ = 9.91048 and the residual is 10.3 − 9.91048 = 0.389524, the largest in the list. SSE is 0.307048, the residual standard error 0.277059 and R² = 0.995414.

Frequently asked questions

How do you calculate a residual?

Residual = measured y − predicted ŷ on the regression line. For x = 5 it is 10.3 − 9.91048 = 0.389524.

Why do residuals sum to zero?

The least-squares line passes through the centroid (x̄ | ȳ), so the deviations above and below cancel exactly.

What does a residual pattern tell me?

If residuals scatter randomly around zero, the line fits. A curve points to a curved relationship, a funnel to growing spread.

Sources and legal basis

As of: · Editorial policy

Related tools