Residuals

Learn what a residual is, how to compute residuals in a table, and how a residual plot shows whether a line fits the data.

Advanced25 minLesson

Definition

A residual is the vertical distance between a data point and the regression line. It tells you how far the line's prediction missed the real value:
e=y−y^e = y - \hat{y}
  • yy is the observed value (what really happened)
  • y^\hat{y} is the predicted value from the line (read "y-hat")
  • ee is the residual, always observed minus predicted
The sign of a residual tells you where the point lies:
  • e>0e > 0: the point is above the line (the line predicted too little)
  • e<0e < 0: the point is below the line (the line predicted too much)
  • e=0e = 0: the point is exactly on the line
A residual has the same unit as yy. For the least-squares regression line, the residuals always add up to zero: ∑e=0\sum e = 0.

Try it now

Which formula gives the residual of a data point?

Worked Examples

The regression line for hours studied (xx) and test score (yy) is y^=5x+50\hat{y} = 5x + 50. Mia studied 44 hours and scored 7272. Find her residual.
1

Find the predicted score

y^=5(4)+50=20+50\hat{y} = 5(4) + 50 = 20 + 50 → y^=70\hat{y} = 70
2

Subtract: observed minus predicted

e=y−y^=72−70e = y - \hat{y} = 72 - 70 → e=2e = 2
3

Interpret the sign

e>0e > 0, so Mia's point lies above the line → She scored 2 points more than predicted

Common Mistakes

Computing predicted minus observed (y^−y\hat{y} - y)

Why it's wrong: This flips every sign: points above the line would get negative residuals and points below would get positive ones.

Correct: Always use observed minus predicted: e=y−y^e = y - \hat{y}. Positive means above the line.

Judging a line by the plain sum of its residuals

Why it's wrong: For the least-squares line the sum is always 00, even when the line fits badly, because positive and negative residuals cancel.

Correct: Square the residuals first and add them (SSR), or look at the residual plot.

Thinking a curved residual plot is fine because the points are close to zero on average

Why it's wrong: A clear curve (U shape, hill shape) means the data follows a bend that a straight line cannot follow.

Correct: A linear model fits only when the residual plot looks like random scatter around 00 with no pattern.

Forgetting the unit or the size of a residual

Why it's wrong: A residual of −3-3 on a test score means 3 points, not 3%. Its size only makes sense in the unit of yy.

Correct: Say it in context: "The line overestimated Leo's score by 3 points."

Interactive Visual

Scatter Plot

Study hours and test scores with residuals

123456556065707580Hours studiedTest score

ŷ = 5x + 50

r = 0.963 · strong positive correlation

Tap a point to see its coordinates.

Scatter Plot

Residual plot: random scatter (linear model fits)

123456-4-2024Hours studiedResidual

residual = 0

Tap a point to see its coordinates.

Scatter Plot

Residual plot: U-shaped curve (linear model does not fit)

123456-7.5-5-2.502.557.5MonthResidual

residual = 0

Tap a point to see its coordinates.

Interactive Sandbox

Expression Calculator

Try these:

History

No calculations yet

Practice Problems

18 problems
Problem 1 of 18
Easy
A data point lies below the regression line. What is the sign of its residual?

Why It Matters

Residuals are how statisticians check a model instead of just trusting it:
  • Is the line any good? Small residuals mean the predictions are close to reality.
  • Is a straight line the right shape? A residual plot (the residuals plotted against x) shows a random cloud when a line fits and a curve when it does not.
  • Which line is best? The least-squares line is the one with the smallest sum of squared residuals.
  • Unusual cases: a very large residual flags a point that does not follow the pattern, such as a typo in the data or a special case.
Weather services, delivery apps, doctors and sports scientists all compare predictions with what really happened, and every one of those comparisons is a residual.

Real World Applications

Delivery Time Estimates

Delivery apps predict the time for an order from the distance. After each delivery, the residual shows whether the estimate was too short or too long.

Example:

With y^=2x+10\hat{y} = 2x + 10 minutes for xx km, a 5 km order is predicted to take 2020 minutes. If it took 1818 minutes, the residual is 18−20=−218 - 20 = -2.

1Try It Yourself

The app's model is y^=2x+10\hat{y} = 2x + 10 (minutes, xx in km). An order over 66 km took 2525 minutes.

What is the residual for this order?

Step 1: Write the mathematical expression

Observed minus predicted:

Plant Growth Experiments

Biologists fit a line to plant height over time. A plant with a large negative residual may be lacking light or water.

Example:

With y^=1.5x+4\hat{y} = 1.5x + 4 cm after xx weeks, a plant is expected to be 1010 cm tall after 4 weeks.

2Try It Yourself

The growth model is y^=1.5x+4\hat{y} = 1.5x + 4 (cm, xx in weeks). After 88 weeks one plant is 14.514.5 cm tall.

What is the residual for this plant?

Step 1: Write the mathematical expression

Observed minus predicted:

Sports Science Models

Coaches predict an athlete's jump height from training data and judge the model by its sum of squared residuals: the smaller, the better.

Example:

If a model misses by 33 cm and −3-3 cm for two athletes, the residuals add to 00, but the squared residuals add to 9+9=189 + 9 = 18.

3Try It Yourself

A least-squares model for jump height has residuals 22, −1-1 and −1-1 cm for three athletes.

What is the sum of squared residuals?

Step 1: Write the mathematical expression

Square each residual and add:

Key Takeaways

  • 1A residual is observed minus predicted: e=y−y^e = y - \hat{y}
  • 2A positive residual means the point is above the line, a negative one means it is below
  • 3Residuals have the same unit as yy and are easiest to organize in a table: xx, yy, y^\hat{y}, ee
  • 4The residuals of the least-squares line always add up to 00
  • 5A residual plot with random scatter around 00 means a line fits; a curved pattern means it does not
  • 6The least-squares line is the line with the smallest sum of squared residuals

Frequently Asked Questions

"Residual" means "what is left over". It is the part of yy that the line does not explain: the value left over after you take away the prediction.
"Residual" means "what is left over". It is the part of yy that the line does not explain: the value left over after you take away the prediction.
Plain residuals cancel out (for the least-squares line their sum is always 00). Squaring makes every miss count as positive and makes big misses count much more.
Not necessarily. It just means the point does not follow the pattern well. Check the data for a typo, but real data can have unusual cases too.
A scatter plot shows xx against yy. A residual plot shows xx against the residual ee, so the regression line becomes the horizontal line e=0e = 0 and any pattern the line missed is easy to see.

Glossary

Residual
Observed value minus predicted value: e=y−y^e = y - \hat{y}
Observed value
The real yy value of a data point, measured or collected
Predicted value
The value y^\hat{y} that the regression line gives for a certain xx
Residual plot
A graph of xx against the residuals, with a horizontal line at 00
Sum of squared residuals (SSR)
The sum ∑(y−y^)2\sum (y - \hat{y})^2; the least-squares line makes it as small as possible
Least-squares line
The regression line with the smallest sum of squared residuals

Formula Card

Residual

e=y−y^e = y - \hat{y}

Observed minus predicted; positive above the line, negative below

Sum of residuals

∑e=0\sum e = 0

Always true for the least-squares regression line

Sum of squared residuals

SSR=∑(y−y^)2\text{SSR} = \sum (y - \hat{y})^2

The least-squares line makes this as small as possible (also written $SS_{\text{res}}$)

Today's challengeOne problem, three tries

More in This Topic