Making Predictions from Data
Predicting a Score Inside the Data
A class recorded hours studied ($x$, from 1 to 8 hours) and test scores ($y$, out of 100). The regression line is $\hat{y} = 5x + 52$. Predict the score of a student who studies $6.5$ hours.
Check where the x-value lies: The data goes from $1$ to $8$ hours, and $1 \le 6.5 \le 8$ = Inside the data: interpolation
Substitute x = 6.5 into the equation: $\hat{y} = 5(6.5) + 52$ = $\hat{y} = 5 \times 6.5 + 52$
Multiply: $5 \times 6.5 = 32.5$ = $32.5$
Add the intercept: $32.5 + 52 = 84.5$ = $\hat{y} = 84.5$
Answer: The predicted score is $84.5$, so about $85$ points. Because $6.5$ hours is inside the data, this is interpolation and the prediction is reasonable.
Working Backwards to a Target
Using $\hat{y} = 5x + 52$, Lena wants to score $80$. About how many hours should she study?
Put the target in place of ŷ: $80 = 5x + 52$ = An equation in $x$
Subtract the intercept from both sides: $80 - 52 = 5x$ = $28 = 5x$
Divide by the slope: $x = \frac{28}{5} = 5.6$ = $x = 5.6$ hours
Round in the direction the goal needs: With $5$ hours: $5(5) + 52 = 77 < 80$. With $6$ hours: $5(6) + 52 = 82 \ge 80$ = Plan about $6$ hours
Answer: The line gives $x = 5.6$ hours (about 5 hours 36 minutes). To be on the safe side for a target, round up: Lena should plan about $6$ hours.
Interpolation or Extrapolation?
With the same line $\hat{y} = 5x + 52$ (data from 1 to 8 hours), predict the score for $3.5$ hours and for $12$ hours. Which prediction can you trust?
Write down the data range: Smallest $x = 1$, largest $x = 8$ = Range: $1$ to $8$ hours
Predict for 3.5 hours (inside the range): $\hat{y} = 5(3.5) + 52 = 17.5 + 52 = 69.5$ = Interpolation: about $70$ points
Predict for 12 hours (outside the range): $\hat{y} = 5(12) + 52 = 60 + 52 = 112$ = Extrapolation: $112$ points
Compare with reality: The test is out of $100$, so $112$ is impossible. The straight-line pattern cannot go on forever. = Only the first prediction is trustworthy
Answer: For $3.5$ hours the prediction is about $70$ points (interpolation, reasonable). For $12$ hours the line gives $112$, which is impossible: extrapolation far outside the data is risky.
Rounding a Prediction Sensibly
A school fair found that visitors follow $\hat{y} = 14.6x + 23$, where $x$ is the number of posters put up (data from 2 to 10 posters). This year they put up $4$ posters. How many visitors should they expect, and how many chairs should they set out?
Check the data range: $2 \le 4 \le 10$ = Interpolation
Multiply the slope by x: $14.6 \times 4 = 58.4$ = $58.4$
Add the intercept: $58.4 + 23 = 81.4$ = $\hat{y} = 81.4$
Round for the situation: People come in whole numbers: about $81$ visitors. For chairs, round up so nobody has to stand. = About $81$ visitors, at least $82$ chairs
Answer: Expect about $81$ visitors. Since the prediction is only an estimate and you need a seat for everyone, set out at least $82$ chairs (a few extra is even safer).
Strong or Weak: How Much Can You Trust It?
The same class has two models. Hours studied: $\hat{y} = 5x + 52$ with $r \approx 0.99$. Hours of sleep: $\hat{y} = 2x + 59$ with $r \approx 0.21$. Predict the score for $7$ hours in each model and compare with the real scores.
Predict with the study model: $\hat{y} = 5(7) + 52 = 35 + 52 = 87$ = The student who studied 7 hours really scored $87$
Predict with the sleep model: $\hat{y} = 2(7) + 59 = 14 + 59 = 73$ = Students who slept 7 hours really scored $62$ and $88$
Measure how far off the sleep prediction is: $73 - 62 = 11$ and $88 - 73 = 15$ = Off by up to $15$ points
Link the accuracy to r: $r \approx 0.99$: points hug the line. $r \approx 0.21$: points are scattered far from the line. = Strong correlation, reliable prediction
Answer: Both predictions use the same method, but only the study model is reliable. With $r \approx 0.21$ the sleep line gives a rough guess that can miss by $15$ points or more.
Mistake: Putting the target y-value in place of x: for a target score of $80$, calculating $5(80) + 52 = 452$
Why: $80$ is a score, so it is a $y$-value. Substituting it for $x$ answers a different question (the score after 80 hours of study).
Correct: Set the equation equal to the target and solve for $x$: $80 = 5x + 52$, so $x = 5.6$.
Mistake: Trusting extrapolation: predicting $112$ points for $12$ hours of study
Why: The pattern was only observed from 1 to 8 hours. Outside that range it can change, and here the score cannot even go above 100.
Correct: Always check the data range first. Mark predictions outside it as extrapolation and treat them with caution.
Mistake: Rounding without thinking about the situation: reporting $84.5$ points as exact, or rounding $5.6$ hours down to $5$
Why: A prediction is an estimate, so extra decimals suggest more precision than it has. Rounding down a target can leave you short (5 hours predicts only 77 points).
Correct: Round to the precision of the data, and round up when you have to reach a goal or cover everyone (time, chairs, buses).
Mistake: Treating every prediction as equally reliable
Why: A line can always be calculated, even for scattered data. With $r \approx 0.21$ the actual values can be far from $\hat{y}$.
Correct: Look at the scatter plot or $r$ first: $|r|$ close to 1 means a reliable prediction, $|r|$ close to 0 means only a rough guess.
Child Growth Charts
Doctors compare a child's height with growth models. A simple model for ages 2 to 10 is $\hat{y} = 6x + 77$, where $x$ is age in years and $\hat{y}$ is height in cm. The model only works for those ages: for an adult of 40 it would predict $317$ cm.
At age 5 the model predicts $6(5) + 77 = 107$ cm.
Delivery Time Estimates
Food delivery apps fit lines to past orders to estimate delivery times. One app found $\hat{y} = 3x + 8$, where $x$ is the distance in km (orders from 1 to 12 km) and $\hat{y}$ is the time in minutes.
For a restaurant 5 km away the app predicts $3(5) + 8 = 23$ minutes.
Phone Battery Forecasts
Phones estimate the remaining battery from how fast it is draining. Measurements while streaming video gave $\hat{y} = 100 - 8x$, where $x$ is hours of video (data from 0 to 10 hours) and $\hat{y}$ is the battery level in percent.
After 6 hours of video the model predicts $100 - 8(6) = 52\%$.
To predict $y$, substitute $x$ into $\hat{y} = mx + b$; $\hat{y}$ is a predicted value, not a measured one
To find the $x$ for a target $y$, set $mx + b$ equal to the target and solve: $x = \frac{y - b}{m}$
Interpolation predicts inside the data range and is usually reasonable
Extrapolation predicts outside the data range and is risky: it can even give impossible values
Round predictions to a sensible precision, and round up when you must reach a goal or cover everyone
Predictions are reliable when $|r|$ is close to 1 and only rough guesses when $r$ is close to 0
Q: Why do we write $\hat{y}$ instead of $y$?
A: The hat shows that the value comes from the line and is a prediction. The real, measured value is $y$. Keeping them apart reminds you that a real result can be above or below the prediction.
Q: Is extrapolation always wrong?
A: Not always. A little outside the data (for example $x = 0$ or $x = 9$ when the data goes from 1 to 8) can still be a fair estimate. The further you go, the more likely the pattern changes, so say clearly that you are extrapolating.
Q: How close to 1 must $r$ be for a good prediction?
A: A common rule of thumb: $|r| \ge 0.7$ is strong, $0.4$ to $0.7$ is moderate and below $0.4$ is weak. Even with a strong correlation, a single prediction can be a few points off.
Q: Can I use the same line to predict $x$ from $y$?
A: Solving $y = mx + b$ for $x$ gives a good estimate for planning, as in the study-hours example. Statisticians fitting a model only to predict $x$ would calculate a separate line with $x$ as the response variable, so treat the answer as an estimate.
Making Predictions from Data
1 / 14
Making Predictions from Data
Use a regression line to predict values, work backwards to a target, and judge when a prediction can be trusted.