math.wiki
Statistics › Bivariate data › Least squares regression › Predicting with a regression line, and extrapolation
Open on the map
Algebra 1 · S.IC.B.6

Predicting with a regression line, and extrapolation

A line has been fitted to the data. What does it say about a case nobody measured, and how far can that answer be trusted?

Where you are 5 in Least squares regression

When you reach for it

A nurse measured nine children, one of each age from 2 to 10 years (made-up data). As (age in years, height in cm) the pairs are (2, 90), (3, 93), (4, 101), (5, 109), (6, 112), (7, 118), (8, 127), (9, 130) and (10, 137). Technology, as in Fitting linear and exponential models with technology, gives the least-squares regression line

\hat{y} = 77 + 6x

where x is the age in years and \hat{y}, read “y-hat”, is the predicted value of the height in centimeters. The hat separates a height the line predicts from a height somebody measured, which is written plain y.

You reach for this line when you know the explanatory variable for a case and want its response: a child’s age is known and the height is not. Sometimes the question runs the other way, from a target response back to the explanatory value. Either way, a second question comes with the first: is this value of x where the data are? In Line of best fit predictions were read from a line drawn by eye; here the line is the least-squares line and the prediction is computed.

The procedure

Substituting the explanatory value

The equation is the line, written as a rule: for each x it gives the height of the line above that x. So a prediction is an evaluation. For a child aged 5.5 years,

\hat{y} = 77 + 6(5.5) = 77 + 33 = 110

The answer carries the response’s units, centimeters, and is reported in a sentence that names both variables: “The line predicts a height of about 110 cm for a child aged 5.5 years.” A number with no units and no context answers nothing.

A prediction is a typical value, not a promise

The dots scatter above and below the line. The 8-year-old in the data is 127 cm tall, and the line says

\hat{y} = 77 + 6(8) = 125

Neither number is wrong. The line describes how height tends to go with age in this group; at a given age it gives the typical, or average, height. One particular 8-year-old can be taller or shorter, and the line makes no promise about any single child. Read \hat{y} as “children of this age are about this tall, on average”. How far one actual case sits from its prediction is its residual, the subject of Interpreting a residual.

Working backwards

To ask which x gives a target prediction, set \hat{y} equal to the target and solve the linear equation for x. The answer is the value of the explanatory variable at which the predicted response reaches the target. Example 3 works one.

Inside or outside the data

Where a model holds: domain, interpolation and extrapolation gives the words: a prediction at an x inside the stretch of the data (here ages 2 to 10) is interpolation; one outside it is extrapolation. For a regression line the difference has a sharp reason. The least-squares line was chosen to sit as close as possible to the dots, and the dots live between x = 2 and x = 10. Nothing outside that stretch had any say in the line. Inside, every prediction has measured cases on both sides of it; outside, the line’s straightness is an assumption that nothing measured supports.

0 4 8 12 16 20 24 28 32 0 40 80 120 160 200 240 280 age (years) height (cm) 257 cm at age 30 ages measured
Figure 1Nine children (made-up data) and the line \hat{y} = 77 + 6x. Carried out to age 30, the line predicts a height of 257 cm.

Real patterns break that assumption in ways a line cannot see: growth that stops (children stop getting taller in their teens, so the line’s 257 cm at age 30 is absurd), a value that cannot go negative (a height, a count), and a time that cannot keep falling (practice shortens a time, but never below 0).

How far is too far is a judgment, not a rule. No fixed distance or percentage separates a safe step past the data from an unsafe one. A short step is often reasonable when what you know about the situation says the pattern carries on; a long step needs a reason from outside the data, and usually there is none. The same distance can be harmless in one setting and wrong in another.

Only as good as the fit

A prediction inherits the quality of the line. If the dots curve, or spread widely about the line, predictions are poor even inside the data. Whether a straight line suits the data at all is checked with Making and reading residual plots, and the strength of a straight-line pattern is measured by The correlation coefficient.

Worked examples

Example 1

Predicting a child’s height

Use \hat{y} = 77 + 6x to predict the height of a child aged (a) 4.5 years and (b) 9.5 years, and say what each prediction means.

Solution

Both ages lie between 2 and 10, so both predictions are interpolation.

(a) Substitute x = 4.5: \hat{y} = 77 + 6(4.5) = 77 + 27 = 104. The line predicts that children aged 4.5 years are about 104 cm tall, on average.

(b) Substitute x = 9.5: \hat{y} = 77 + 6(9.5) = 77 + 57 = 134. The line predicts a typical height of about 134 cm at age 9.5.

Check against the data: the 4- and 5-year-olds measured 101 and 109 cm, and 104 sits between them; the 9- and 10-year-olds measured 130 and 137 cm, and 134 sits between them.

Example 2

A line with decimal coefficients

Dolores measured a bamboo shoot every second day from day 10 to day 20 after it appeared (made-up data). As (day, height in cm): (10, 149), (12, 203), (14, 266), (16, 325), (18, 380), (20, 444). Technology gives \hat{y} = -148 + 29.5x. Predict the height on day 15 and on day 19.

Solution

Substitute each day for x, multiplying before adding:

\begin{aligned} \text{day } 15: \ \hat{y} &= -148 + 29.5(15) \\ &= -148 + 442.5 = 294.5 \\ \text{day } 19: \ \hat{y} &= -148 + 29.5(19) \\ &= -148 + 560.5 = 412.5 \end{aligned}

The line predicts a height of about 294.5 cm on day 15 and about 412.5 cm on day 19. Both days lie inside 10 to 20, and each prediction sits between the heights measured on the days either side (266 and 325 cm, then 380 and 444 cm). Here the line describes one shoot over time, so “typical” means the steady trend through the day-to-day ups and downs.

The intercept -148 is not a height the shoot ever had; Example 5 says why.

Example 3

Working backwards to an age

At what age does the line \hat{y} = 77 + 6x predict a height of 120 cm?

Solution

Set the prediction equal to the target and solve. Subtracting 77 from both sides and then dividing both sides by 6 keeps the equation true at each step:

\begin{aligned} 77 + 6x &= 120 \\ 6x &= 43 \\ x &= \tfrac{43}{6} \approx 7.2 \end{aligned}

The line predicts a typical height of 120 cm at about 7.2 years, which is about 7 years and 2 months, since 0.17 \times 12 \approx 2. The age 7.2 is inside 2 to 10, so this rests on the data. Check: 77 + 6\left(\tfrac{43}{6}\right) = 77 + 43 = 120.

Example 4

Three ages, three judgments

Use \hat{y} = 77 + 6x at ages 11, 30 and 0, and decide how far to trust each prediction.

Solution
\begin{aligned} x = 11: \quad \hat{y} &= 77 + 66 = 143 \\ x = 30: \quad \hat{y} &= 77 + 180 = 257 \\ x = 0: \quad \hat{y} &= 77 + 0 = 77 \end{aligned}

All three are extrapolation, since the data stop at ages 2 and 10.

Age 11 is one year past the oldest child. Children of 10 are still growing steadily, so a short step is a reasonable guess, offered with the warning that no 11-year-old was measured.

Age 30 gives 257 cm, taller than nearly anyone who has ever lived. Most people stop growing by their late teens, so height levels off; the line has no way to know this, because every dot it was fitted to is a child who was still growing. The figure shows the dashed line climbing on at 6 cm a year long after real growth has stopped.

Age 0 gives 77 cm, but a newborn baby is much shorter, around half a meter. Growth in the first two years is faster than 6 cm a year, so the line, which only saw ages 2 to 10, starts too high.

The three are all outside the data, yet only one is worth anything. What decided it was knowledge of how children grow, not a rule about distance.

Example 5

Growth that stops

Dolores kept measuring her bamboo shoot after day 20. Use \hat{y} = -148 + 29.5x to predict its height on day 60 and on day 0, and compare with what happened.

0 10 20 30 40 50 60 0 300 600 900 1200 1500 1800 days since the shoot appeared height (cm) line: 1622 cm on day 60 later measurements used
Figure 2Dolores’s bamboo shoot (made-up data). The line fitted to days 10 to 20 keeps climbing; the shoot itself stopped.
Solution

Day 60: \hat{y} = -148 + 29.5(60) = -148 + 1770 = 1622, a prediction of 1622 cm, over 16 meters. The rings show that the shoot slowed after day 20 and stopped at 870 cm by day 50. A bamboo stem reaches its full height in its first season and does not grow taller after that. The prediction is 1622 - 870 = 752 cm too high, nearly double the real height.

Day 0: \hat{y} = -148, a negative height, which is impossible. The line reaches 0 where 29.5x = 148, at x \approx 5.0, so it claims the shoot was below ground until about day 5. The shoot appeared on day 0, so it must have grown more slowly than 29.5 cm a day at first: slow growth and then fast growth make a curve that a line through days 10 to 20 cannot show.

Both failures have one cause. The line was fitted to days 10 to 20, a stretch of fast, steady growth, and it describes those days well. Outside them it simply keeps going at 29.5 cm a day in both directions.

Boundaries

  • The equation must be a least-squares line for the data in hand, with x the explanatory variable. Predicting for cases unlike the ones measured (another kind of bamboo, children from a different population) is a guess even at an x inside the data.
  • A prediction is a typical value for that x. It says nothing exact about one case.
  • Interpolation is trusted only as far as the fit is good: a line through curved or widely scattered dots predicts poorly everywhere.
  • Inside the stretch of the data, a wide gap with no dots in it gives a prediction there little support, even though it counts as interpolation.
  • Solving backwards gives the x at which the predicted y reaches a target; a line fitted to predict x from y would usually give a slightly different answer.
  • How far outside the data is too far has no fixed answer; it is decided by what is known about the situation.

Where this goes next

A prediction and a measured value seldom agree, and the gap between them, actual minus predicted, is a residual: Interpreting a residual reads one, and Making and reading residual plots uses all of them together to judge whether a straight line was the right model to predict from at all.

Exercises

Making predictions

  1. Use \hat{y} = 77 + 6x (children’s heights in cm, ages 2 to 10) to predict the height at age 3.5 and at age 9. Write a sentence in context for age 9.
  2. Decima recorded how full a parking lot was, as a percentage of its spaces, at minutes after it opened (made-up data): (10, 27), (20, 38), (30, 54), (40, 70), (50, 81). The least-squares line is \hat{y} = 12 + 1.4x. Predict how full it is 25 minutes and 35 minutes after opening.
  3. Dietrich weighed 20 bunches of bananas holding 4 to 12 bananas each (made-up data, not shown). The least-squares line for the mass in grams is \hat{y} = 18 + 152x, where x is the number of bananas. Predict the mass of a bunch of 9 bananas, and say what the prediction tells you about one bunch of 9 bananas on a shelf.
  4. Use Dolores’s bamboo line \hat{y} = -148 + 29.5x to predict the height on day 13.

Working backwards

  1. For the parking lot line \hat{y} = 12 + 1.4x, how many minutes after opening does the line predict it is 75\% full?
  2. At what age does \hat{y} = 77 + 6x predict a height of 100 cm? Give the age to one decimal place.
  3. For the banana line \hat{y} = 18 + 152x, what number of bananas gives a predicted mass of 1000 g? What does the answer mean, given that a bunch holds a whole number of bananas?

Inside or outside the data

  1. For the parking lot data, which of 15, 45, 60 and 90 minutes give interpolation? Use the line to predict how full the parking lot is at 90 minutes, and comment.
  2. Edmund timed his average solve of a puzzle cube, in seconds, in each of his first 8 weeks of practice (made-up data): (1, 94), (2, 87), (3, 82), (4, 81), (5, 77), (6, 70), (7, 67), (8, 66). The least-squares line is \hat{y} = 96 - 4x. Predict his time in week 10 and in week 30. In which week does the line reach 0 seconds?
  3. What does the bamboo line \hat{y} = -148 + 29.5x give on day 0? Explain why that is not the shoot’s height on the day it appeared.
  4. The children’s line predicts 173 cm at age 16. Check the number, say whether it is interpolation or extrapolation, and say whether you would trust it.

Reasoning

  1. Two 8-year-olds measure 120 cm and 131 cm. The line \hat{y} = 77 + 6x predicts 125 cm. Does either child show the line is wrong? Explain.
  2. Consider the claim: “The dots lie almost exactly on the line, so the line can be used at any x at all.” Explain what is wrong with this reasoning.
  3. Consider a proposed rule: “a prediction up to 10\% beyond the data is safe; beyond that, it is not.” Explain why no rule of this kind can work, using the children’s line and the bamboo line.
  4. Suppose the nurse had measured only children aged 2, 3, 4, 9 and 10. A prediction at age 6.5 would still be interpolation. Explain why it would deserve less trust than it does with all nine ages.
Answers
  1. 98 cm and 131 cm. 77 + 6(3.5) = 77 + 21 = 98 and 77 + 6(9) = 77 + 54 = 131. The line predicts that 9-year-olds are about 131 cm tall, on average.
  2. 47\% and 61\%. 12 + 1.4(25) = 12 + 35 = 47 and 12 + 1.4(35) = 12 + 49 = 61. Both are inside 10 to 50 minutes.
  3. 1386 g. 18 + 152(9) = 18 + 1368 = 1386. This is the typical mass of bunches of 9 bananas; one particular bunch can be heavier or lighter, since bananas differ in size.
  4. 235.5 cm. -148 + 29.5(13) = -148 + 383.5 = 235.5, between the 203 cm and 266 cm measured on days 12 and 14.
  5. 45 minutes. 12 + 1.4x = 75 gives 1.4x = 63, so x = 45, inside the data.
  6. About 3.8 years. 77 + 6x = 100 gives 6x = 23, so x = \tfrac{23}{6} \approx 3.8 (about 3 years and 10 months).
  7. About 6.46 bananas. 18 + 152x = 1000 gives 152x = 982, so x \approx 6.46. No bunch holds 6.46 bananas: the line predicts 930 g for 6 bananas and 1082 g for 7, so a predicted 1000 g falls between bunches of 6 and bunches of 7.
  8. 15 and 45 minutes are interpolation; 60 and 90 are extrapolation. At 90 minutes, 12 + 1.4(90) = 12 + 126 = 138, so 138\%, which is impossible: a parking lot cannot be more than 100\% full. The line passes 100\% at x = \tfrac{88}{1.4} \approx 62.9 minutes; the real filling must slow and stop before then.
  9. 56 s in week 10 and -24 s in week 30. 96 - 4(10) = 56 and 96 - 4(30) = -24. The line reaches 0 when 4x = 96, in week 24. Week 10 is a short step past the data and may be roughly right; a negative time is impossible, because practice can shorten a time but never below 0.
  10. -148 cm. On day 0 the shoot was just appearing, with a height near 0, never negative. The line was fitted to days 10 to 20 only, so day 0 is extrapolation, and the early growth was slower than the steady 29.5 cm a day of those days.
  11. Extrapolation. 77 + 6(16) = 77 + 96 = 173, and 16 is six years past the oldest child measured. Children’s growth slows and stops during the teens, so the line’s steady 6 cm a year has no support there; 173 cm is not absurd, but nothing measured backs it.
  12. No. The line gives the typical height of 8-year-olds, not every 8-year-old’s height. Children of one age vary, so heights 5 cm below and 6 cm above the prediction are what scatter about a line looks like.
  13. A close fit is evidence about the x values he measured, and only those. Outside that stretch the pattern can bend, level off or stop, as the bamboo did, and the data cannot show it either way.
  14. The safe distance depends on the situation, not on a percentage. For the children, 10\% past age 10 is age 11, a step children’s steady growth makes reasonable. For the bamboo, 10\% past day 20 is day 22, and the shoot was already slowing just after day 20: the line gives 589.5 cm on day 25, against 560 cm measured, and the gap only grows after that. A small step is reasonable in one setting and not in the other, so only knowledge of the setting decides.
  15. With nine ages, a prediction at 6.5 has measured children at 6 and 7 either side of it, so the line has been checked right there. With no data between 4 and 9, the line is only assumed straight across that gap, much as it is assumed outside the data, and growth there could differ without the data showing it.
kg1128 · updated 2026-10-10 · CC-BY-SA-4.0