# What are the residuals?

Finds the residual y − ŷ of every point from the least-squares regression line, with the predicted values, the sum of squared residuals (SSE), and the residual standard deviation.

- Page: https://www.acalculator.org/statistics/residual-calculator
- JSON spec: https://www.acalculator.org/statistics/residual-calculator.json
- Version: b126525711cc

## Default answer

Example with the default inputs (x values [1, 2, 3, 4, 5], y values [2, 4, 5, 4, 5]): The residuals from ŷ = 0.6x + 2.2 are −0.8, 0.6, 1, −0.6, −0.2.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| x | x values | The x values, in order, separated by commas, spaces, semicolons, or new lines. |
| y | y values | The observed y values, one for each x value, in the same order. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| residuals | Residuals (y − ŷ) | The residual of each point, in the order you entered them. |
| equation | Regression line | The least-squares line, each coefficient to 6 significant digits. |
| slope | Slope (b) | How much ŷ changes when x goes up by 1. |
| intercept | Intercept (a) | The value of ŷ where x = 0. |
| sse | Sum of squared residuals (SSE) | Each residual squared, then added up. |
| residualSd | Residual standard deviation (s) | The square root of SSE ÷ (n − 2). It needs 3 or more points. |
| n | Number of points (n) | How many (x, y) pairs there are. |

## Method

b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)²; a = ȳ − b x̄; ŷ = a + bx; residual = y − ŷ; SSE = Σ(y − ŷ)²; s = √(SSE ÷ (n − 2)).

## Assumptions

- The line is the least-squares regression line of y on x, fitted to all the points you enter.
- A positive residual means the point is above the line; a negative one, below it.
- The residuals of a least-squares line with an intercept always add up to 0.

## Worked examples

1. x = 1 or 2, y = 2 or 4 gives residuals = −0.8, 0.6, 1, −0.6, −0.2, equation = ŷ = 0.6x + 2.2, slope = 0.6, intercept = 2.2, sse = 2.4, residualSd = 0.894427, n = 5. Source: OpenStax, Introductory Statistics 2e, §12.3 The Regression Equation (the residual is y − ŷ, positive above the line; SSE is the sum of the squared residuals, which the least-squares line minimises), https://openstax.org/books/introductory-statistics-2e/pages/12-3-the-regression-equation (retrieved 2026-10-05).
2. x = 0 or 1, y = 10 or 7 gives residuals = 0, 0, 0, 0, equation = ŷ = −3x + 10, sse = 0, residualSd = 0. Source: OpenStax, Introductory Statistics 2e, §12.3 The Regression Equation (the residual is y − ŷ, positive above the line; SSE is the sum of the squared residuals, which the least-squares line minimises), https://openstax.org/books/introductory-statistics-2e/pages/12-3-the-regression-equation (retrieved 2026-10-05).
3. x = 0.1 or 0.2, y = 0.3 or 0.1 gives residuals = 0.05, −0.1, 0.05, equation = ŷ = −0.5x + 0.3, sse = 0.015. Source: OpenStax, Introductory Statistics 2e, §12.3 The Regression Equation (the residual is y − ŷ, positive above the line; SSE is the sum of the squared residuals, which the least-squares line minimises), https://openstax.org/books/introductory-statistics-2e/pages/12-3-the-regression-equation (retrieved 2026-10-05).

## FAQ

### What is a residual?

A residual is the observed value minus the predicted value: e = y − ŷ. It is the vertical distance from a point to the regression line. A point above the line has a positive residual, and a point below it a negative one.

### How do I calculate a residual?

Find the regression line ŷ = a + bx, put the point's x into it to get ŷ, and subtract ŷ from the observed y. For the default data the line is ŷ = 0.6x + 2.2; at x = 3 it gives 4, and the observed y is 5, so the residual is 1.

### What is the sum of squared residuals?

SSE is each residual squared, then added up. The least-squares line is the line that makes SSE as small as possible. For the default data SSE = 2.4.

### Why do the residuals add up to zero?

For a least-squares line with an intercept, the positive and negative residuals always balance, so their sum is 0. The line passes through the point of means (x̄, ȳ).

### What does a residual plot show?

It plots each residual against x. If a straight line suits the data, the residuals scatter around 0 with no pattern. A curve or a funnel shape in the residuals suggests a different model, such as quadratic regression, or a spread that changes with x.

### What is the residual standard deviation?

It is s = √(SSE ÷ (n − 2)), the typical size of a residual. It needs at least 3 points, because 2 points always lie exactly on their line.

## Sources

- OpenStax, Introductory Statistics 2e, §12.3 The Regression Equation: the residual y − ŷ is positive for a point above the line and negative below it; SSE is the sum of the squared residuals, which the least-squares line minimises. https://openstax.org/books/introductory-statistics-2e/pages/12-3-the-regression-equation (retrieved 2026-10-05)
