A delivery service has fitted a line relating trip time to distance, and a dispatcher asks two questions about 12 km trips. What is the average time of all such trips, and how long will the next one take? Both answers start from the same fitted value, but the second is far less certain, because a single trip varies around the average however well the average is known. This lesson builds the confidence interval for a mean response and the wider prediction interval for one new observation, and explains why neither formula makes a prediction outside the observed range trustworthy.
Key terms
Mean response
Definition In the simple linear regression model
where the errors have mean at every predictor value, the mean response at a predictor value is the conditional mean
It is a fixed, unknown population quantity. It is estimated by the fitted value , where and are the least-squares coefficients. One new observation at is a different target, , because it carries its own error.
In plain words The mean response is the average outcome over all units in the population with that predictor value, such as the average time of all 12 km trips. The same fitted value serves as the estimate of that average and as the point prediction for one new trip, but the two targets come with different amounts of uncertainty.
Example Take the constructed sample with predictor values and responses . Least squares gives with residuals , so . With residual degrees of freedom the residual variance estimate is . The predictor mean is and the sum of squared predictor deviations is . At the estimated mean response is , and is also the point prediction for one new observation there.
Confidence interval for a mean response
Definition Assume the model above with a correct linear mean, with predictor values treated as fixed, and with errors that are independent, have the same variance at every and are normally distributed. Suppose and the data contain at least two distinct predictor values. Let and define
Then , the standard error is , and has the distribution. The confidence interval for the mean response at is
The coverage is pointwise. For one value fixed in advance, the procedure covers in a proportion of repeated samples. Intervals at several predictor values all cover at once with a smaller probability in general, and a band meant to cover the whole line at once, such as the Working-Hotelling band, uses a larger multiplier.
In plain words The term comes from estimating the height of the line at , which is as hard as estimating an average from observations. The second term grows with the squared distance from to the center of the predictor values, because an error in the estimated slope moves the line more the farther you are from . So the interval is narrowest at and widens toward the edges of the data. When is one of the observed predictor values, is the hat value of an observation there. The interval describes the population average, not the spread of individual responses.
Example In the six-point sample, . At the center the distance term vanishes, so and . The margin is about , and the 95 percent interval is about . At the edge ,
which is about , so and the interval around is about . In a simulation of this design, the six pointwise 95 percent intervals at all covered their means in only about 89 percent of samples.
Prediction error
Definition Let be a new observation at that follows the same model independently of the fitting sample. The prediction error of the fitted value is
Under the model it has mean , its two parts are independent, the first has variance and the second has variance , so
The estimated standard error of prediction is . If the target is instead the average of new observations at with independent errors, the new-error part has variance and the variance of the prediction error is .
In plain words Under the model, a prediction misses for two reasons. The fitted line is somewhat off from the true mean line, and the new unit varies around the true mean. More fitting data shrinks the first part, since falls toward when grows and the predictor values keep their spread. The second part is the population’s own variation around its mean, and no amount of fitting data removes it.
Example At in the six-point sample, the estimated variance is for the mean part and for the new error. The standard error of prediction is , against for the mean response. For the average of four new independent observations at it is , between the two. If the four observations share a source of variation, such as the same driver on the same day, the term understates the new-error variance.
Prediction interval
Definition Under the same model with normal errors, and for a new observation at that follows the model independently of the fitting sample, the ratio has the distribution. The prediction interval for the new observation is
The probability that the interval contains the new observation is computed over both the fitting sample and the new observation. At the same and level, the prediction interval is wider than the confidence interval for the mean response whenever .
In plain words A prediction interval targets one future outcome, a random quantity, rather than a fixed parameter. It leans on the normal shape of the errors much more than the interval for the mean does. With a large sample the interval for the mean is approximately valid under milder conditions, but the new error is a single draw, so the coverage of the prediction interval depends on the shape of the error distribution at every sample size. The 95 percent is also an average over fitting samples. It does not promise that 95 percent of future observations will fall inside one particular computed interval, and it is pointwise, like the interval for the mean.
Example At the 95 percent prediction interval is about , or , while the confidence interval for the mean response is . The data, the fitted line, the center and the level are the same, yet the prediction interval is times as wide, because it addresses a more variable target. At the edge the prediction interval is about , against for the mean.
Extrapolation
Definition Extrapolation is using a fitted model to estimate a mean response or predict an outcome at predictor values outside the range of the data used for fitting, or more broadly for a population or conditions the data did not represent. The formulas still return intervals there, and the growing makes them wider. That extra width accounts only for sampling variability within the assumed model. It does not account for a true relation that bends beyond the observed range or for a population that is different there.
In plain words Inside the data, a straight line that fits badly can show up as a pattern in the residuals. Outside the data there are no residuals to check, so the coverage claim rests entirely on the assumption that the line continues. A wider interval is not a validated one.
Example The six-point sample covers predictor values from to . At the fitted value is and
which is about . The 95 percent confidence interval for the mean response is about and the prediction interval is about . If the true mean response levels off after and stays at , the mean at lies well below both intervals, and nothing in the six observations could have revealed that.
Check yourself
- A fitted line relates trip time in minutes to distance in kilometers for a city’s delivery trips. Which interval answers each request, and what multiplies in the variance it uses? The requests are the average time of all 12 km trips, the time of the next 12 km trip, and the average time of the next four 12 km trips, assuming those four trips are independent.
Show the answer
The average of all 12 km trips is a mean response, so it calls for the confidence interval with variance factor . The next trip is one new observation, so it calls for the prediction interval with factor . The average of four new independent trips calls for a prediction interval for a future average, with factor . All three are centered at the same fitted value, and their widths are ordered from the mean response, narrowest, to the single trip, widest.
- A least-squares fit to independent trips gives , with time in minutes and distance in kilometers, residual SD minutes, km and . Assuming the regression conditions hold, find the 95 percent confidence interval for the mean time of 11 km trips and the 95 percent prediction interval for one new 11 km trip, using . Explain why the first can be narrow while the second is wide.
Show the answer
The fitted value is minutes, and
For the mean response, , the margin is about , and the interval is about minutes. For one new trip, the standard error of prediction is , the margin is about , and the interval is about minutes. Twenty trips pin down the average time at 11 km fairly well, but individual trips scatter around that average with an SD of about minutes, and the fitting data do nothing to reduce the next trip’s own error.
- The data in the previous question cover distances from 2 to 15 km. A manager proposes two things. First, collect trips over the same range of distances so that the prediction interval for one 11 km trip becomes about a minute wide. Second, use the current fit to predict a 40 km trip, arguing that the interval there is wide and therefore safe. Evaluate both proposals.
Show the answer
With trips spread like the original ones, grows to about and drops to about . If the new estimate is still about minutes, the margin for the mean response shrinks to about minutes, but the prediction margin only falls to about minutes, because the factor never drops below . The prediction interval stays about minutes wide, far from a minute, as long as individual trips scatter with an SD near minutes. For the 40 km trip the formula gives and a prediction margin of about minutes around minutes. That width assumes the straight line continues far past 15 km, which the data cannot check. Longer trips may use different roads or include stops, so the interval has no validated coverage there.