Statisticsdrill

Regression and correlation Updated November 2026

Residuals

A residual is the gap between an observed value and the value the regression predicts: e = y - y-hat. Positive residuals sit above the line, negative below. Least squares residuals always sum to zero, and their pattern in a residual plot tells you whether the linear model fits.

Syntax

e = y - y-hat = y - (a + b * x)
PartWhat it is
ythe observed value
y-hatthe predicted value from the fitted line

Examples

Line y-hat = 2.2 + 0.6x; point (3, 5)
y-hat = 2.2 + 1.8 = 4.0; e = 5 - 4.0

Result: 1.0 (the point is above the line)

All five points x: 1..5, y: 2, 4, 5, 4, 5
predicted: 2.8, 3.4, 4.0, 4.6, 5.2
residuals: -0.8, 0.6, 1.0, -0.6, -0.2

Result: sum = 0, SSE = 2.4

Excel: =B1 - FORECAST.LINEAR(A1, $B$1:$B$5, $A$1:$A$5), filled down

Residual standard error
s = sqrt(SSE / (n - 2)) = sqrt(2.4 / 3)

Result: 0.894

Excel: =STEYX(B1:B5, A1:A5)

Common mistakes

  • Subtracting in the wrong order (y-hat - y); the convention is observed minus predicted, so a point above the line has a positive residual.
  • Ignoring a curved or fanning pattern in the residual plot; residuals should look like random noise around zero, any pattern means the model is missing something.
  • Calling a large residual an error in the data; it may be a real unusual case, check it before deleting it.

Practice Residuals

These drills check your answer on live data, free, no account needed.

  • Residual of one observationData on monthly ad spend and sales at regional stores (x = Ad spend ($k), y = Sales ($k)): (9, 87.8), (10, 98.7), (6, 81.3), (12, 99.1), (15, 111.9), (6, 78.6). Fit the least squares line. What is the residual for observation 4, at x = 12? Round to 2 decimal places.
  • Predicted value from a fitted lineData on monthly ad spend and sales at regional stores (x = Ad spend ($k), y = Sales ($k)): (9, 87.8), (10, 98.7), (6, 81.3), (12, 99.1), (15, 111.9), (6, 78.6). Fit the least squares line and predict y when x = 11. Round to 2 decimal places.

Questions

What should a residual plot look like?

A shapeless horizontal band around zero. A curve means the relationship is not linear; a funnel means the spread changes with x (heteroscedasticity); a trend over time means autocorrelation.

Why do residuals sum to zero?

Because the least squares line with an intercept passes through the point of means; the positive and negative gaps balance exactly.

What is a standardized residual?

The residual divided by its standard error, so it reads like a z-score. Values beyond about 2 or 3 flag points the model fits poorly.

Related

  • Linear regressionHow to fit a regression line y = a + bx: slope b = Sxy / Sxx, intercept a = y-bar - b x-bar, a worked example, prediction and Excel SLOPE and INTERCEPT.
  • R-squaredR-squared is the share of variation in y explained by the regression, 1 - SSE / SST. Worked example with exact numbers, link to r, Excel RSQ and its limits.
  • OutliersHow to detect outliers with the 1.5 IQR fence rule and the z-score rule, worked examples with exact fences, and what to do with outliers once found.
  • Standard errorThe standard error of the mean is s / sqrt(n); for a proportion it is sqrt(p(1 - p) / n). Worked examples, SE versus standard deviation and the Excel formula.

Previous: R-squaredNext: Covariance