Line of Best Fit
A line of best fit is a straight line drawn through the middle of the points on a scatter plot. It shows the overall trend of the data. You can write its equation in slope-intercept form, y = mx + b, and use it to make predictions. It is also called a trend line or line of fit.
Before this lesson: You should know scatter plots and correlation, slope-intercept form and writing equations in slope-intercept form.
What Is a Line of Best Fit?
Real data almost never falls exactly on a line. But when a scatter plot shows a linear pattern, one line can sum it up. That line is the line of best fit.
Here is the study-time data from the last lesson. The line runs through the middle of the cloud, with some points above it and some below.
| Hours studied | 1 | 2 | 2 | 3 | 4 | 4 | 5 | 6 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|---|---|
| Quiz score | 62 | 65 | 70 | 72 | 75 | 80 | 84 | 85 | 90 | 92 |
How to Find a Line of Best Fit
By eye
- Make a scatter plot and check that the pattern looks linear.
- Draw a straight line through the middle of the points. Try to have about as many points above it as below.
- Pick two points on your line. They don’t have to be data points.
- Find the slope: m = \frac{y_2 - y_1}{x_2 - x_1}.
- Use one point to find b, and write y = mx + b.
With a calculator
A graphing calculator or app can find the exact line of best fit. This is called linear regression. For the study data, it gives y = 5.06x + 57.28 with r \approx 0.98.
What the slope and y-intercept mean
The slope is the rate of change. Here, each extra hour of study goes with about 5 more points on the quiz. The y-intercept, 57.28, is the predicted score for 0 hours of study.
Worked Examples
Example 1: Write an equation for a line drawn by eye
A student draws a line of fit for the study data. It passes through (1, 62) and (7, 92). Write its equation.
\begin{aligned} m &= \frac{92 - 62}{7 - 1} = \frac{30}{6} = 5 \\ 62 &= 5(1) + b \\ b &= 57 \end{aligned}The equation is y = 5x + 57. It is very close to the calculator’s line.
Example 2: Interpret the slope and y-intercept
Use y = 5.06x + 57.28. What do 5.06 and 57.28 mean?
The slope 5.06 means each extra hour of study goes with about 5.06 more points. The y-intercept 57.28 means a student who studies 0 hours is predicted to score about 57.
Example 3: Make a prediction
Predict the score for a student who studies 5.5 hours.
y = 5.06(5.5) + 57.28 = 27.83 + 57.28 = 85.11
The predicted score is about 85.
Example 4: Find a residual
A residual is the actual value minus the predicted value. Find the residual for the point (4, 80).
\begin{aligned} \text{predicted} &= 5.06(4) + 57.28 = 77.52 \\ \text{residual} &= 80 - 77.52 = 2.48 \end{aligned}The residual is about 2.5. It is positive, so the point is above the line. For (4, 75), the residual is 75 - 77.52 = -2.52, so that point is below the line.
Example 5: When not to trust a prediction
Use the line to predict the score for 10 hours of study.
y = 5.06(10) + 57.28 = 107.88
A quiz score can’t be more than 100. The data only goes up to 7 hours, so the line may not hold at 10 hours. Predicting far outside the data is called extrapolation, and it can be wrong. Predicting inside the data is safer.
Common Mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Joining the first and last points | Drawing the line from the lowest point to the highest | Go through the middle of all the points, with about as many above as below. |
| Trying to hit every point | Bending the line to touch each dot | A line of best fit is straight. Most points will be off the line. |
| Residual with the wrong sign | Residual = predicted − actual | Residual = actual − predicted. A positive residual means the point is above the line. |
| Trusting predictions far from the data | Predicting a quiz score of 108 | Only predict inside or close to the data’s range. |
| Mixing up slope and r | Saying the slope is 0.98 | r shows how strong the fit is. The slope is the rate of change, here 5.06. |
Practice Problems
Problems 1 to 7 use this data. A café records the outside temperature (°F) and cups of hot cocoa sold.
| Temperature (°F) | 40 | 45 | 50 | 55 | 60 | 65 | 70 |
|---|---|---|---|---|---|---|---|
| Cups sold | 50 | 47 | 40 | 37 | 30 | 27 | 20 |
- What type of correlation does the data show?
- A line of fit passes through (40, 51) and (70, 21). Write its equation.
- What does the slope of your line mean?
- Use your line to predict cups sold at 58°F.
- Find the residual for the point (50, 40) using your line.
- A calculator gives y = -1.00x + 90.86. Use it to predict cups sold at 62°F.
- Would it make sense to use the line to predict sales at 100°F? Explain.
- Line A has residuals 3, −2 and 1. Line B has residuals 6, −5 and 4 for the same points. Which line fits better?
- For the study data, what does the y-intercept of y = 5x + 57 mean?
Show answers
- A strong negative correlation. As the temperature goes up, cocoa sales go down.
- m = \frac{21 - 51}{70 - 40} = \frac{-30}{30} = -1. Then 51 = -1(40) + b, so b = 91. The line is y = -x + 91.
- For each 1°F warmer, the café sells about 1 fewer cup of cocoa.
- y = -58 + 91 = 33 cups.
- Predicted: -50 + 91 = 41. Residual: 40 - 41 = -1. The point is 1 cup below the line.
- y = -1.00(62) + 90.86 = 28.86, so about 29 cups.
- No. The line gives y = -100 + 91 = -9, and you can’t sell a negative number of cups. 100°F is far outside the data, so this is extrapolation.
- Line A, because its residuals are smaller. Its points are closer to the line.
- A student who studies 0 hours is predicted to score 57.
FAQ
How do you find the line of best fit?
Draw a line through the middle of the points, then use two points on it to find the slope and y-intercept. For an exact line, use linear regression on a calculator.
What is the difference between a line of best fit and linear regression?
Linear regression is a method for finding the line of best fit. It finds the line that keeps the residuals as small as possible.
What is a residual?
It is the actual y-value minus the predicted y-value. Positive residuals are above the line, and negative ones are below it.
Can a line of best fit go through none of the points?
Yes. It only needs to follow the overall trend. It may pass through some points, or none at all.
Summary
- A line of best fit shows the trend in a scatter plot.
- Draw it through the middle of the points, or use linear regression.
- Write it as y = mx + b. The slope is the rate of change.
- A residual is actual minus predicted.
- Predictions are best inside the range of the data.
Previous lesson: Scatter Plots and Correlation
Next course: Geometry Index
Back to the Algebra 1 Index
