If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Introduction to residuals

Build a basic understanding of what a residual is. 
We run into a problem in stats when we're trying to fit a line to data points in a scatter plot. The problem is this: It's hard to say for sure which line fits the data best.
For example, imagine three scientists, Andrea, Jeremy, and Brooke, are working with the same data set. If each scientist draws a different line of fit, how do they decide which line is best?
A graph plots points on an x y plane. Points are rising diagonally in a weak scatter between (1 half, 1 half) and (10, 7). Three different colored lines are plotted. The red line passes through (1, 3) and (10 and 1 half, 5 and 1 half). The green line passes through (1, 2) and (10 , 6). The blue line passes through (0, 1 half) and (10 and 1 half, 7 and 1 half). All values are estimated.
If only we had some way to measure how well each line fit each data point...

Residuals to the rescue!

A residual is a measure of how well a line fits an individual data point.
Consider this simple data set with a line of fit drawn through it
A graph plots points on an x y plane. Points are at (1, 2), (2, 8), (4, 3), (6, 7), and (8, 8). A line increases diagonally from the point (0, 3) through the point (10, 8). All values are estimated.
and notice how point (2,8) is 4 units above the line:
A graph plots points on an x y plane. Points are at (1, 2), (2, 8), (4, 3), (6, 7), and (8, 8). A line increases diagonally from the point (0, 3) through the point (10, 8). An green arrow labeled 4 extends vertically from the line up to the point at (2, 8). All values are estimated.
This vertical distance is known as a residual. For data points above the line, the residual is positive, and for data points below the line, the residual is negative.
For example, the residual for the point (4,3) is 2:
A graph plots points on an x y plane. Points are at (1, 2), (2, 8), (4, 3), (6, 7), and (8, 8). A line increases diagonally from the point (0, 3) through the point (10, 8). An green arrow labeled 4 extends up vertically from the line up to the point at (2, 8). A red arrow labeled negative 2 extends down vertically from the line to the point at (4, 3). All values are estimated.
The closer a data point's residual is to 0, the better the fit. In this case, the line fits the point (4,3) better than it fits the point (2,8).

Try to find the remaining residuals yourself

What is the residual of the point (6,7) in the graph above?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3/5
  • a simplified improper fraction, like 7/4
  • a mixed number, like 1 3/4
  • an exact decimal, like 0.75
  • a multiple of pi, like 12 pi or 2/3 pi

What is the residual of the point (8,8) in the graph above?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3/5
  • a simplified improper fraction, like 7/4
  • a mixed number, like 1 3/4
  • an exact decimal, like 0.75
  • a multiple of pi, like 12 pi or 2/3 pi

What is the residual of the point (1,2) in the graph above?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3/5
  • a simplified improper fraction, like 7/4
  • a mixed number, like 1 3/4
  • an exact decimal, like 0.75
  • a multiple of pi, like 12 pi or 2/3 pi

Want to join the conversation?

  • aqualine seed style avatar for user just.play.game.forever
    what is the difference between error and residual?
    (50 votes)
    Default Khan Academy avatar avatar for user
    • female robot grace style avatar for user tyersome
      I think ysun means that:
      An error is a deviation from the population mean.
      A residual is a deviation from the sample mean.

      Errors, like other population parameters (e.g. a population mean), are usually theoretical.
      Residuals, like other sample statistics (e.g. a sample mean), are measured values from a sample. Sample statistics are often used to estimate population parameters, so in this case the residuals can be used to estimate the error.
      (52 votes)
  • starky tree style avatar for user imamulhaq
    How do you do this On a calculator
    (12 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Joona Rauhamäki
    This article does not explain what to do with the residuals after calculating them. Are you supposed to sum them? When are you supposed to use them?
    (12 votes)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user Jacob Kovacs
      The article is incomplete. It didn't circle back around to answer the question it posed at the beginning: "If each scientist draws a different line of fit, how do they decide which line is best?" Calculating the residuals for each line helps you decide which line best fits the data.
      (14 votes)
  • duskpin ultimate style avatar for user G-Port
    If you have a really positive residual point that is quite far form the LSRL is that good or bad ? Like what can you say about the residual?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • female robot grace style avatar for user tyersome
      That would be what is called an "outlier".

      It could suggest that the measurement that led to that point was wrong — e.g. The value was 3000, but 30000 got entered by mistake.

      Another possibility, especially if there aren't a lot of data points, is that the relationship between the variables is not linear — e.g. an exponential curve might be a better fit....

      ADDENDUM: It is also possible that the data is actually very "noisy" (highly variable).
      (8 votes)
  • blobby green style avatar for user owen-k
    Really dumb question: Why is it called least squares regression? What does least squares mean?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • purple pi pink style avatar for user ZeroFK
      The "squares" refers to the squares (that is, the 2nd power) of the residuals, and the "least" just means that we're trying to find the smallest total sum of those squares.

      You may ask: why squares? The best answer I could find is that it's easy (minimizing a quadratic formula is easy) and still gives good results.
      (7 votes)
  • blobby green style avatar for user alyssah83
    how can a residual be one sided? For example in the graphs, would being one sided mean the data points are not scattered?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • purple pi teal style avatar for user Parsa Abangah
      In statistics, resids (short for residuals) are the differences between the predicted values and the actual values of the response variable. One-sided residuals can occur when a model is fitted to data with some specific characteristics. A one-sided residual plot is a plot of residual values against the fitted values of the model only for one side of the graph.

      For example, a one-sided residual plot can be observed when we have a regression model in which our residuals are constrained to be non-negative. In this case, we may have a one-sided residual plot resulting from the fact that only one side of the graph will have positive residuals, while the other side will have residuals of zero.

      In terms of scatterplots, being one-sided does not necessarily mean that the data points are not scattered. The scatter in the data points will still be visible in the one-sided residual plot.
      (2 votes)
  • blobby green style avatar for user kylie839692
    how can you summarize a residual plot?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Charlotte Pierrel
    What are estimates ? How are they different from residuals ?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user bmanoff47
    If there are many points on a graph then how can you draw a line that is best for all of them?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • female robot grace style avatar for user tyersome
      The line you make is a compromise that minimizes some function of the residuals.
      The most commonly used function is the sum of squares of the residuals. You cannot just do the sum of the values of the residuals, since there are likely to be many lines for which that will be zero.
      (2 votes)
  • winston baby style avatar for user Iustus82437
    in residuals how do you determine which one is best? do you mean it or do you do something else this article did not tell me how to.
    (4 votes)
    Default Khan Academy avatar avatar for user