Learn · Algebra 1

Lines of fit and residuals

Fit a line to a scatter plot, explain its slope and y-intercept in context, make predictions, and use residuals to judge direction and strength.

Lesson 2 of 5About 30 minutesMA.912.DP.2.4MA.912.DP.2.6

Written with AI assistance. No teacher has reviewed these lessons and questions yet.

01 · Learn the idea

A line that stands in for the data

A scatter plot shows pairs of numbers as points. Each point is one thing measured two ways: a plant’s age and its height, a day’s temperature and that day’s sales. When the points rise or fall together in a rough straight band, you can draw one line through the middle of the band. That line is called a line of fit.

Here is a small case. A class measured one sunflower seedling every two days. The numbers are invented for this lesson. Days since sprouting, x: 2, 4, 6, 8, 10, 12 and height in centimeters, y: 6, 8, 12, 17, 23, 24.

The heights climb by about 4 cm every 2 days, which is about 2 cm per day. No straight line passes through all six points, but the line y = 2x + 1 runs through the middle of them. Two points sit above it, three sit below it, and one sits right on it.

There are two ways to get a line of fit. You can draw it by eye with a ruler, or you can let a graphing calculator or spreadsheet find the least-squares line, the one line that makes the squared vertical misses add up to the smallest possible total. For the seedling data, technology gives exactly y = 2x + 1.

  • y = 2x + 1
Six seedling points rise from (2, 6) to (12, 24), with the line of fit y = 2x + 1 passing through the middle of them.

02 · Build understanding

Worked example: fit a line by eye and read it

Use the seedling data again. Days x: 2, 4, 6, 8, 10, 12 and height in cm y: 6, 8, 12, 17, 23, 24. Fit a line by eye, then say what its slope and y-intercept mean.

Step 1: Plot the points and look at the trend. The points rise from left to right in a fairly straight band, so a line is a reasonable model.

Step 2: Lay a ruler through the band so that the points are balanced above and below it. Read two points on your ruler line that are easy to read and far apart. They do not have to be data points. Suppose your line passes through (2, 5) and (12, 25).

Step 3: Find the slope from those two points. Slope = (25 − 5)/(12 − 2) = 20/10 = 2.

Step 4: Find the y-intercept. Put (2, 5) into y = 2x + b. You get 5 = 2(2) + b, so b = 1. The line of fit is y = 2x + 1.

Step 5: Say what the slope means, with units. The slope is 2 cm per day. The model predicts that the seedling grows about 2 cm each day.

Step 6: Say what the y-intercept means. When x = 0, y = 1. The model predicts a height of about 1 cm on day 0, the day the seedling sprouted.

Step 7: Check. At x = 12 the line gives 2(12) + 1 = 25, which matches the second ruler point. The measured height on day 12 was 24 cm, only 1 cm away.

y = 2x + 1

03 · Build understanding

Worked example: predict with a line of fit

Jo runs laps on a track and checks her water bottle every two laps. The numbers are invented. Laps run, x: 2, 4, 6, 8, 10, 12 and water left in ounces, y: 28, 22, 21, 20, 14, 12. A spreadsheet gives the least-squares line y = −1.5x + 30.

Step 1: Read the line before you use it. The slope is −1.5, so the model says Jo drinks about 1.5 ounces per lap. The y-intercept is 30, so the model says the bottle held about 30 ounces before the first lap.

Step 2: Predict inside the data. This is called interpolation. After 7 laps, y = −1.5(7) + 30 = 19.5 ounces. Seven laps sits between measured laps, so this prediction is on firm ground.

Step 3: Predict outside the data. This is called extrapolation. After 16 laps, y = −1.5(16) + 30 = 6 ounces. Nobody measured past 12 laps, so trust this less. Jo might slow down or drink faster late in the run.

Step 4: Push the line too far and it breaks. After 24 laps the model gives −1.5(24) + 30 = −6 ounces. A bottle can’t hold a negative amount of water. The further you go past the data, the less the line can be trusted.

Step 5: Work backward when the question gives y. When will 9 ounces be left? Solve 9 = −1.5x + 30. Subtract 30 to get −21 = −1.5x, then divide by −1.5 to get x = 14 laps.

Step 6: Check. −1.5(14) + 30 = −21 + 30 = 9 ounces.

04 · Build understanding

Worked example: residuals

A residual measures how far one data point misses the line, straight up or down. Residual = actual y − predicted y. A positive residual means the point is above the line. A negative residual means it is below. Find the residuals for the seedling data and the line y = 2x + 1.

Step 1: Find the predicted height for each day by putting x into the line. For x: 2, 4, 6, 8, 10, 12 the predicted heights are 5, 9, 13, 17, 21, 25.

Step 2: Subtract predicted from actual, in that order. 6 − 5 = 1, 8 − 9 = −1, 12 − 13 = −1, 17 − 17 = 0, 23 − 21 = 2 and 24 − 25 = −1.

Step 3: Read the residuals. The largest miss is 2 cm, on day 10. The heights themselves spread from 6 cm to 24 cm, a range of 18 cm. Misses of 2 cm or less are small next to a spread of 18 cm, so the points hug the line.

Step 4: Check. The residuals add to 1 − 1 − 1 + 0 + 2 − 1 = 0. A least-squares line always balances its misses this way, with the positive and negative residuals canceling.

  • y = 2x + 1
The seedling points and the line y = 2x + 1, with a short vertical segment from each point to the line showing its residual.

05 · Build understanding

Direction and strength of a correlation

A correlation is a linear pattern between two numerical variables. You describe it with two words: one for direction and one for strength.

Direction comes from the slope of the line of fit. A positive slope means y tends to go up as x goes up, a positive correlation. A negative slope means y tends to go down as x goes up, a negative correlation. The seedling line has slope 2, so that correlation is positive. Jo’s water line has slope −1.5, so that one is negative.

Strength comes from the residuals. When the residuals are small next to the spread of the y-values, the points sit close to the line and the correlation is strong. When the residuals are large, the points are scattered and the correlation is weak.

Jo’s water data has residuals 1, −2, 0, 2, −1, 0. No miss is more than 2 ounces, while the amounts spread from 12 to 28 ounces. That is a strong negative correlation.

Now picture a second seedling with heights 11, 3, 7, 17, 33, 19 on the same six days. Technology gives the same line, y = 2x + 1, but the residuals are 6, −6, −6, 0, 12, −6. A miss of 12 cm is huge next to a spread of 30 cm. The direction is still positive, but the correlation is much weaker than the first seedling’s, and predictions from this line deserve much less trust.

06 · Build understanding

Three mistakes to watch for

Subtracting a residual backward. On day 10 the seedling was 23 cm tall and the line predicted 21 cm. The residual is 23 − 21 = 2. Writing 21 − 23 = −2 says the point is below the line when it is above it.

Mixing up the slope and the y-intercept. In y = −1.5x + 30, the 30 is where the bottle starts, in ounces. The −1.5 is how fast the water goes down, in ounces per lap. Saying "Jo drinks 30 ounces per lap" swaps the two.

Judging strength by steepness. A steep line can have a weak correlation and a gently sloped line can have a strong one. Both seedling data sets share the slope 2, yet one has misses of at most 2 cm and the other has a miss of 12 cm. Strength is about how close the points are to the line.

Apply and explain

Your turn

An invented iced tea stand recorded hours of sunshine, x, from 2 to 9 hours, and cups sold, y. The line of fit is y = 6x + 10, and every residual is between −3 and 3 cups, while sales ranged from 20 to 65 cups. Explain what the slope and y-intercept mean, describe the direction and strength of the correlation, and say how much you would trust a prediction for a day with 15 hours of sunshine.

Use paper or explain your thinking aloud before opening the solution.

Check your reasoning

The slope 6 means the model predicts about 6 more cups sold for each extra hour of sunshine. The y-intercept 10 means the model predicts about 10 cups on a day with 0 hours of sunshine. The slope is positive, so the correlation is positive. The residuals are at most 3 cups while sales spread over 45 cups, so the points are close to the line and the correlation is strong. For 15 hours the line gives 6(15) + 10 = 100 cups, but 15 is far outside the 2 to 9 hours that were measured, so that prediction is an extrapolation and should be trusted much less.

  • Explains the slope as about 6 cups per extra hour of sunshine and the y-intercept as about 10 cups at 0 hours.
  • Names the direction as positive from the slope and the strength as strong from the small residuals.
  • Computes 100 cups for 15 hours and says it is an extrapolation that deserves less trust.

Ready to practice?

Try the questions, get feedback, and review your reasoning.

Lines of fit and residuals: practice →