Business Analytics & Data Science

B06 · Intermediate

Regression Analysis

10 lessons

B06 · Module 2, lesson 2 · Lesson 4 of 10

Prediction and intervals

Use a fitted line to predict, and say how far to trust the prediction: the confidence interval for the average at a given x against the prediction interval for one new case, why both widen away from the mean of x, why the prediction interval never shrinks below the residual spread, and why extrapolation escapes them both. Then roster a Saturday’s peak from a weather forecast, by hand and in Excel.

About 75 minutes

Before you start

You will be able to

  • Calculate a point prediction ŷ₀ = b₀ + b₁x₀ for a new x, and explain why the same number estimates both the average at x₀ and a single new case.
  • Calculate the confidence interval for the mean response and the prediction interval for one new case, using 1/n + (x₀ − x̄)²/Sxx, by hand and with FORECAST.LINEAR, STEYX, DEVSQ and T.INV.2T.
  • Explain why both intervals are narrowest at x̄ and widen away from it, and why the prediction interval can’t shrink below about ±t × s however much data there is.
  • Identify extrapolation, both beyond the range of x and to conditions the sample didn’t cover, and explain why no interval allows for it.
  • Use a prediction bound to make a planning decision, and state what the prediction interval assumes about the errors.

Review first

Fictional case A fictional coffee business founded by Ana Lim. It starts as a catering and barista-training service, opens its own cafés and an online shop for beans, and plans a canned cold brew.

The idea

Fictional case

Friday’s forecast for Saturday is a high of 80°F and no rain. Harbourside’s manager has to set the 7–11 a.m. barista roster tonight, and Ana’s rule is to keep peak transactions per barista hour at about 7 or fewer, where B05 found that waits stay short. The previous lesson’s 49 weekend days give ŷ = 26.10 + 1.005x. How many transactions should the manager plan for, and how sure can she be?

A point prediction, and two questions it answers

Put the forecast into the line: y^0=26.10+1.005×80=106.5\hat{y}_0 = 26.10 + 1.005 \times 80 = 106.5 transactions. That single number, the point prediction, answers two different questions, and they need different intervals.

  • What is the average number of transactions on weekend days with a high of 80°F? This is a question about the population line at x₀ = 80, the mean response. Its uncertainty comes only from not knowing β₀ and β₁ exactly.
  • How many transactions will there be this Saturday? This is a question about one new day. Its uncertainty includes the line’s and, on top, the day’s own error ε: rain that wasn’t forecast, a coach party, a quiet morning.

The first gets a confidence interval for the mean response, from 100.5 to 112.5 transactions. The second gets a prediction interval, from 75.3 to 137.8. The manager is rostering one Saturday, so the prediction interval is hers. Its width is the honest summary: even with a good model and a reliable forecast, a single 80°F Saturday could plausibly bring anything from about 75 to 138 transactions.

Where the widths come from

Both intervals are y^0±tn−2∗×\hat{y}_0 \pm t^{*}_{n-2} \times a standard error. For the mean response,

SEmean=s1n+(x0−xˉ)2SxxSE_{\text{mean}} = s\sqrt{\dfrac{1}{n} + \dfrac{(x_0 - \bar{x})^2}{S_{xx}}}
=15.24×149+(80−64.35)213,529=2.99= 15.24 \times \sqrt{\dfrac{1}{49} + \dfrac{(80 - 64.35)^2}{13{,}529}} = 2.99

and for a single new case one more s2s^2 goes under the square root, for the new day’s own error:

SEpred=s1+1n+(x0−xˉ)2SxxSE_{\text{pred}} = s\sqrt{1 + \dfrac{1}{n} + \dfrac{(x_0 - \bar{x})^2}{S_{xx}}}
=15.24×1+0.0204+0.0181=15.53= 15.24 \times \sqrt{1 + 0.0204 + 0.0181} = 15.53

With t47∗=2.012t^{*}_{47} = 2.012, the intervals are 106.5±2.012×2.99106.5 \pm 2.012 \times 2.99 (100.5 to 112.5) and 106.5±2.012×15.53106.5 \pm 2.012 \times 15.53 (75.3 to 137.8). The 1 under the second root dominates: the line is known to within about 3 transactions at 80°F, but a single day scatters about it by about 15.

Harbourside’s 49 weekend days from July: transactions against the day’s high, with the fitted line, the 95% confidence interval for the mean (shaded) and the 95% prediction interval for one new day (dashed). Both are narrowest at the mean high, 64°F.

In depth

Why the intervals widen away from x̄

The term (x0−xˉ)2/Sxx(x_0 - \bar{x})^2 / S_{xx} is zero at the mean of x and grows with the square of the distance from it. The least-squares line always passes through (xˉ,yˉ)(\bar{x}, \bar{y}); an error in its slope swings it round that point like a seesaw, so the line is pinned most firmly in the middle of the data and least at the ends. At x0=xˉx_0 = \bar{x} the standard error of the mean response is simply s/n=15.24/7=2.18s/\sqrt{n} = 15.24/7 = 2.18, the standard error of a mean; at 80°F it is 2.99 and at the warmest day in the data, 94°F, 4.45.

Predicted transactions and 95% intervals at four highs (49 weekend days; t* = 2.012 on 47 df)
High (°F)ŷ₀Interval for the meanPrediction interval
64.3 (x̄)90.886.4 to 95.259.8 to 121.7
80106.5100.5 to 112.575.3 to 137.8
94 (warmest day)120.6111.6 to 129.588.6 to 152.5
100 (beyond the data)126.6116.2 to 137.094.2 to 159.0

The interval for the mean more than doubles in width from x̄ to 94°F, while the prediction interval hardly moves: the day’s own error, s, dwarfs the uncertainty in the line. That is typical of business data with a modest R² (here 0.56). Better estimates of the line help the mean much more than the single case; only a better model, one that explains more of each day’s scatter, narrows the prediction interval substantially.

The seesaw also says where data are most useful. A prediction at the warm end is helped by more warm days, which pull xˉ\bar{x} towards 80°F, and by a wide spread of highs, which raises SxxS_{xx}. A sample of days all near 64°F would predict 64°F well and 90°F badly, even with the same n and the same s. If a model will be used mostly at one end of its range (Ana rosters with care on hot weekends, rarely on cold ones), that end is where the data should be densest.

The prediction interval’s floor

As n grows, 1/n1/n and (x0−xˉ)2/Sxx(x_0 - \bar{x})^2/S_{xx} both shrink towards 0, so SEmean→0SE_{\text{mean}} \to 0 but SEpred→sSE_{\text{pred}} \to s. With ten years of weekends Ana would know the average at 80°F almost exactly, and a single Saturday would still range about ±1.96 × 15 transactions. Penn State’s STAT 462 puts it this way: the prediction interval is always wider than the confidence interval at the same x, and the extra term never goes away. The only way to narrow it is to reduce s itself. Rain is the obvious candidate: with the day’s rain in the model as well (multiple regression, module 3), s falls from 15.24 to 12.91.

Extrapolation

The intervals assume the straight line holds at x0x_0. Inside the data’s range, 33°F to 94°F, the data can check that; outside it, nothing can. A forecast of 100°F gives ŷ = 126.6 with a prediction interval of 94.2 to 159.0, but the interval only measures uncertainty about a line that is assumed to continue. Real trade may level off as the waterfront becomes too hot to sit in, or the café may simply run out of seats. That is extrapolation, and NIST’s e-Handbook lists poor extrapolation among the main weaknesses of linear least squares. OpenStax’s statistics texts draw the same line between interpolation (predicting inside the observed x values) and extrapolation (outside them).

Extrapolation is not only about x. Ana’s 49 days are Harbourside weekends from July, after the café had built up its regulars. Applied to March, inside the range of temperatures but outside the period, the line overpredicts every one of the eight March weekend days, by 16 transactions on average: the café was still in its first months. The same model is equally unfit for a weekday, for Millbrook, or for a festival day. A prediction is safe only for cases like the ones the model was fitted to, in x and in everything the model leaves out.

What the prediction interval assumes

The interval for the mean leans on the same conditions as the slope’s inference; the prediction interval leans on them harder, because it describes where one error will fall, not where an average will.

  • Equal spread. The interval has the same half-width (apart from the small seesaw term) at every x. If the spread grows with the mean, it is too wide for cool days and too narrow for warm ones. The case’s generator is multiplicative, so this is the direction to expect; in these 49 days the residuals’ standard deviation is 15.8 on days of 70°F or more against 13.2 below 55°F, a modest difference the Breusch–Pagan test can’t distinguish from chance.
  • Roughly normal errors. The ±t × SE recipe sets the 95% limits where a normal error would put them. For the slope, the central limit theorem rescues the interval as n grows; for one new case it doesn’t, because a single error is not an average. Skewed errors make one tail of the prediction interval too short at any n. Module 4’s normal Q–Q plot checks this.
  • Independence and the right model. The day must be like those the model was fitted to, and the model must not have left out a trend that has moved since.

A rough check is how many of the fitted days fall outside their own 95% prediction intervals: here 2 of 49 (4%), about the 5% expected. That is reassuring, though not a test: the intervals were computed from the same days.

Reporting a prediction

A prediction is only useful with four things beside it: the point value, the interval and which kind it is, the confidence level, and the scope (the range of x and the kind of case the model was fitted to). Software names the two intervals differently: OpenStax’s business statistics text calls them the confidence interval and the prediction interval, Penn State’s course the confidence interval for the mean response and the prediction interval for a new response, and some statistical packages label them “mean” and “obs” (observation). Whatever the label, ask whether it contains the 1 under the square root. If a report gives a single interval for a forecast without saying which, ask; one much narrower than the residual standard error suggests is probably the interval for the mean.

In Excel

The ToolPak’s Regression tool prints no interval for a new x, so build them from functions. With the highs in B2:B50, transactions in C2:C50 and the new high in F1:

  • Point prediction: =FORECAST.LINEAR(F1,C2:C50,B2:B50) (new x first, then known_y’s, then known_x’s; Microsoft’s page notes it replaced FORECAST in Excel 2016). =TREND(C2:C50,B2:B50,F1) gives the same value.
  • The pieces: s is =STEYX(C2:C50,B2:B50), Sxx is =DEVSQ(B2:B50), n is =COUNT(B2:B50) and the multiplier is =T.INV.2T(0.05,COUNT(B2:B50)-2).
  • Half-width of the prediction interval: =T.INV.2T(0.05,COUNT(B2:B50)-2)*STEYX(C2:C50,B2:B50)*SQRT(1+1/COUNT(B2:B50)+(F1-AVERAGE(B2:B50))^2/DEVSQ(B2:B50)). Drop the 1+ for the interval for the mean.

One-sided bounds for planning

A 95% prediction interval leaves 2.5% in each tail. A roster only worries about the upper tail: too few baristas is the costly mistake. A one-sided upper bound puts all the risk on that side: y^0+t0.90, n−2×SEpred\hat{y}_0 + t_{0.90,\,n-2} \times SE_{\text{pred}} is exceeded on about 10% of such days, if the model and its conditions hold. At 80°F that is 106.5+1.300×15.53=126.7106.5 + 1.300 \times 15.53 = 126.7 transactions, with 1.300 from =T.INV(0.9,47). Which tail probability to accept is a business choice, the cost of an idle barista against the cost of long waits; the statistics only price each choice.

Formulas

Point prediction

y^0=b0+b1x0\hat{y}_0 = b_0 + b_1 x_0
y^0\hat{y}_0
Predicted y at the new x: the estimated mean response, and the best single guess for one new caseunits of y
b0,b1b_0, b_1
Fitted intercept and slopeunits of y; per unit of x
x0x_0
The new value of xunits of x

Excel: =FORECAST.LINEAR(x0,known_y's,known_x's) or =TREND(known_y's,known_x's,x0).

Confidence interval for the mean response

y^0±tn−2∗ s1n+(x0−xˉ)2Sxx\hat{y}_0 \pm t^{*}_{n-2}\, s\sqrt{\dfrac{1}{n} + \dfrac{(x_0 - \bar{x})^2}{S_{xx}}}
y^0\hat{y}_0
Point prediction at x₀units of y
tn−2∗t^{*}_{n-2}
Critical t; for 95%, T.INV.2T(0.05, n − 2)
ss
Residual standard error (STEYX)units of y
nn
Number of rows
x0,xˉx_0, \bar{x}
The new x and the mean of the data’s xunits of x
SxxS_{xx}
Sum of squared deviations of x (DEVSQ)units of x squared

Assumes. The LINE conditions; x₀ inside the range and conditions of the data.

Narrowest at x₀ = x̄, where it is ŷ ± t* × s ÷ √n.

Prediction interval for one new case

y^0±tn−2∗ s1+1n+(x0−xˉ)2Sxx\hat{y}_0 \pm t^{*}_{n-2}\, s\sqrt{1 + \dfrac{1}{n} + \dfrac{(x_0 - \bar{x})^2}{S_{xx}}}
y^0\hat{y}_0
Point prediction at x₀units of y
tn−2∗t^{*}_{n-2}
Critical t on n − 2 df
ss
Residual standard errorunits of y
11
The new case’s own error variance, in units of s²
nn
Number of rows
x0,xˉx_0, \bar{x}
The new x and the mean of xunits of x
SxxS_{xx}
Sum of squared deviations of xunits of x squared

Assumes. As for the mean, and more strongly: constant spread at every x and roughly normal errors, at any sample size.

Never narrower than about ±t* × s, however large n is.

One-sided upper prediction bound

y^0+t1−α, n−2  s1+1n+(x0−xˉ)2Sxx\hat{y}_0 + t_{1-\alpha,\,n-2}\; s\sqrt{1 + \dfrac{1}{n} + \dfrac{(x_0 - \bar{x})^2}{S_{xx}}}
t1−α, n−2t_{1-\alpha,\,n-2}
One-sided critical t: T.INV(1 − α, n − 2), e.g. T.INV(0.9, n − 2) for a bound exceeded about 10% of the time
y^0\hat{y}_0
Point predictionunits of y
ss
Residual standard errorunits of y
nn
Number of rows
x0,xˉx_0, \bar{x}
The new x and the mean of xunits of x
SxxS_{xx}
Sum of squared deviations of xunits of x squared

Used when only one side of the error is costly (a roster, a stock level, a capacity).

Worked examples

A first example: How many cones on an 80-degree day?

Fictional figures

Ferrybridge Ice Cream (fictional), from the previous lesson: eight days, highs from 62°F to 88°F, ŷ = −65.70 + 2.971x, s = 4.803 cones, x̄ = 74°F, Sxx = 510. Tomorrow’s forecast is 80°F. Give the 95% interval for the average number of cones on 80°F days, and the 95% prediction interval for tomorrow.

  1. Point prediction: y^0=−65.70+2.971×80=171.98\hat{y}_0 = -65.70 + 2.971 \times 80 = 171.98 cones with the rounded coefficients; 171.95 with the unrounded ones, which the rest of the working uses.
  2. Distance term: (80−74)2/510=36/510=0.0706(80 - 74)^2 / 510 = 36/510 = 0.0706; with 1/n=0.1251/n = 0.125, the sum is 0.1956.
  3. Standard errors: SEmean=4.803×0.1956=2.124SE_{\text{mean}} = 4.803 \times \sqrt{0.1956} = 2.124; SEpred=4.803×1.1956=5.252SE_{\text{pred}} = 4.803 \times \sqrt{1.1956} = 5.252.
  4. Multiplier: =T.INV.2T(0.05,6) = 2.447. Interval for the mean: 171.95±2.447×2.124171.95 \pm 2.447 \times 2.124, 166.8 to 177.1. Prediction interval: 171.95±2.447×5.252171.95 \pm 2.447 \times 5.252, 159.1 to 184.8.

Answer. About 172 cones; 95% interval for the average at 80°F: 166.8 to 177.1; 95% prediction interval for tomorrow: 159.1 to 184.8 cones.

What it means. To decide how much mix to make for tomorrow the kiosk needs the prediction interval: about 185 cones covers all but an unlucky day. The interval for the average would suit a different question, such as the season’s plan for 80-degree days. With only eight days, the 1/n term is large, so the line’s own uncertainty is a sizeable part of the prediction interval here, unlike in Ana’s 49 days.

A harder example: Near the middle, at the edge, and beyond

Fictional figures

Using Harbourside’s 49 weekend days, compare the 95% intervals at the mean high (64.3°F), at 94°F (the warmest day in the data) and at 100°F. Then judge a prediction for a Saturday in March with a forecast of 50°F.

  1. At x̄ = 64.3°F: the distance term is 0, so SEmean=s/n=15.24/7=2.18SE_{\text{mean}} = s/\sqrt{n} = 15.24/7 = 2.18 and SEpred=15.241+1/49=15.39SE_{\text{pred}} = 15.24\sqrt{1 + 1/49} = 15.39. ŷ = 90.8; intervals 86.4 to 95.2 (mean) and 59.8 to 121.7 (one day).
  2. At 94°F: (94−64.35)2/13,529=0.065(94 - 64.35)^2/13{,}529 = 0.065, so SEmean=4.45SE_{\text{mean}} = 4.45 and SEpred=15.88SE_{\text{pred}} = 15.88. ŷ = 120.6; intervals 111.6 to 129.5 and 88.6 to 152.5. The mean’s interval has doubled; the prediction interval has widened by about 3%.
  3. At 100°F: ŷ = 126.6, prediction interval 94.2 to 159.0, barely wider than at 94°F. The formula can’t see that no day in the data was above 94°F: it assumes the line continues. The interval is not wrong arithmetic; it is the answer to a question the data can’t support.
  4. March at 50°F: inside the range of highs, so the formula gives ŷ = 76.4 with an ordinary-looking interval. But the model was fitted to July–December, after the café’s build-up, and on all eight March weekend days it overpredicted, by 16 transactions on average. The March prediction is extrapolation in time.

Answer. At x̄ the intervals are narrowest (±4.4 and ±31.0); at 94°F the mean’s interval doubles while the prediction interval barely changes; at 100°F and in March the formula still gives intervals, but they rest on assumptions the data can’t check.

What it means. Distance from x̄ matters for the line’s uncertainty; distance from the data matters for whether the line applies at all. Only the first appears in the formula. Ana should use the model for warm weekends inside 33–94°F in the second half of the year, and refit when she has a full year of established trade.

Applied: a business decision: Rostering an 80-degree Saturday

Fictional figures

Saturday’s forecast at Harbourside is 80°F and dry. Peak (7–11 a.m.) transactions are 55% of the day’s, and Ana’s rule is about 7 peak transactions per barista hour. On the 14 weekend days in the sample with highs of 78°F or more, the roster gave 6.5 to 7.5 barista hours. How many barista hours should the manager roster, using the mean, the 95% prediction interval and a one-sided 90% upper bound?

  1. At the point prediction, 106.5 transactions: 0.55 × 106.5 = 58.6 peak transactions, ÷ 7 = 8.4 barista hours.
  2. At the 95% prediction interval’s upper end, 137.8: 0.55 × 137.8 ÷ 7 = 10.8 barista hours.
  3. At the one-sided 90% upper bound, 106.5 + 1.300 × 15.53 = 126.7: 0.55 × 126.7 ÷ 7 = 10.0 barista hours.
  4. Compare with practice: 6.5 to 7.5 hours on warm weekends means loads of about 8 to 9 at the predicted trade, above Ana’s rule. B05’s rule keeps the expected peak load at about 7, which means rostering to ŷ: 8.4 hours, or 8.5 in half-hour steps. That puts the load above 7 on about half of such Saturdays. The one-sided 90% bound is Ana’s stricter choice of tail risk: a load above 7 on about one Saturday in ten.
  5. Check the conditions: Saturday is a weekend day after the build-up, the forecast is inside 33–94°F, and it is dry, while the model averages over wet and dry days, so a dry 80°F day is likely to come in a little above the line.

Answer. Roster 10 barista hours (the one-sided 90% bound, in half-hour steps): about 2.5 baristas across the four-hour peak, against the 6.5–7.5 hours warm weekends have been getting.

What it means. The prediction interval turns a forecast into a staffing risk Ana can choose. Ten hours leaves about a one-in-ten chance of a load above 7 if the model holds; 8.5 hours, the rule’s own roster, would be cheaper and leave it near even odds. The model ignores rain, and the forecast is dry. Dry weekend days in the sample came in about 4 transactions above the line on average, but a model with rain also has smaller residuals (s of 12.91 against 15.24), and the two effects roughly cancel: the rain model’s one-sided 90% bound for a dry 80°F day is 127.5 transactions against 126.7 here, and the dry days in the sample exceeded this lesson’s bound 9.7% of the time. The roster is the decision; the regression only prices the options.

Explore

The weekend model with prediction boxes. Enter 80 for the high and read ŷ = 106.5, the interval for the mean (100.5 to 112.5) and the prediction interval (75.3 to 137.8). Try 64.3, the mean high, then 94 and 33, and watch the interval for the mean widen while the prediction interval hardly moves. Then try 100, outside the data: the widget still answers, which is exactly the danger.

Loading the interactive…

Half-widths of the two intervals across the range of highs, for a chosen confidence level and size of sample. The chart shows the interval for the mean bowing out from the middle and the prediction interval sitting on its floor of about ±t × s. Raise n to see the mean’s interval shrink towards 0 while the prediction interval doesn’t.

Loading the interactive…

The calculation in Excel: FORECAST.LINEAR for ŷ, then STEYX, DEVSQ, COUNT, AVERAGE and T.INV.2T for the two intervals, and the barista hours at the upper bound. Change the forecast in G1 or the confidence level in G2.

Loading the interactive…

Common mistakes

  • Using the confidence interval for a single day

    The interval for the mean, 100.5 to 112.5 at 80°F, is about the average of all such days. One Saturday scatters about that average by roughly s, so its interval, 75.3 to 137.8, is five times as wide. Rostering to the top of the narrow one under-staffs about a third of such Saturdays.

  • “More data will make the prediction interval as narrow as I like.”

    More data shrinks 1/n and the distance term, not the 1 under the square root. The prediction interval’s floor is about ±t × s; only a model with smaller residuals lowers it.

  • Extrapolating because the formula still gives an answer

    At 100°F, or for a March weekend, FORECAST.LINEAR returns a number and the formula an interval. Neither knows the data stopped at 94°F or began after the café’s build-up. Check that x₀ and the conditions are inside what the model was fitted to.

  • Treating the interval as exact when the spread changes with x

    The prediction interval has nearly the same width at every x. If the spread grows with the mean, as a multiplicative process makes it, the interval is too narrow at the busy end, where mistakes cost most. Check the residual plot (module 4) before trusting the busy end.

  • Mixing up FORECAST.LINEAR’s arguments

    FORECAST.LINEAR takes the new x first, then known_y’s, then known_x’s; SLOPE, INTERCEPT and STEYX take known_y’s first. =FORECAST.LINEAR(80,B2:B50,C2:C50) predicts the high from transactions instead.

Guided practice

Work through these with hints when you need them. Every hint and every worked solution is there to be used.

Loading four questions…

On your own

No hints this time. Answer, check, and read the feedback; the solution appears once you have answered or if you ask for it. Your first answers count toward mastery.

Loading six questions…

In practice

Fictional case

Ana’s weekend rostering sheet now has three columns beside the forecast: the predicted transactions, the one-sided 90% upper bound, and the barista hours at that bound. Her note to the manager reads: “Roster to the bound, rounded to the half hour. The model covers weekends from July to December 2027 between 33°F and 94°F; don’t use it for weekdays, festivals or forecasts outside that range. It ignores rain; on a dry 80°F forecast a model with rain gives almost the same bound (127.5 transactions against 126.7). It will be refitted with rain and the full year once 2028’s spring weekends are in.”

The sheet turns a prediction interval into a rule a manager can follow without statistics, and the note limits the rule to the cases it was built from. That is how prediction is used professionally: a point forecast for the central plan, a prediction bound for capacity, and a written scope. A bakery sets the next day’s bake from a predicted demand plus a margin for the day’s scatter; a call centre staffs to an upper bound on calls; an energy supplier hedges against the upper end of a cold-weather demand forecast.

In each case the width of the interval is itself information. A wide prediction interval says the model leaves a lot of each day unexplained; narrowing it is a job for a better model, with more predictors or a better functional form, not for more decimal places. And the interval for the mean has its own uses: a budget for the season’s average warm Saturday, or a comparison between two cafés’ typical days.

Finally, a prediction is only as good as its inputs. A 95% prediction interval treats the forecast high as known. If the forecast itself might be 5°F out, the transactions it implies are more uncertain still; a slope of about 1 transaction per °F makes that roughly 5 transactions either way, small beside the interval’s ±31 but worth knowing.

Knowledge check

Six questions, one attempt each, no hints. Score 80% or more to complete the lesson; you can take it again at any time.

Loading six questions…

Summary

  • ŷ₀ = b₀ + b₁x₀ estimates both the average at x₀ and a single new case; FORECAST.LINEAR(x₀, known_y’s, known_x’s) computes it.
  • Interval for the mean response: ŷ₀ ± t* × s√(1/n + (x₀ − x̄)²/Sxx). Prediction interval for one new case: the same with 1 + under the root.
  • Both are narrowest at x̄ and widen with (x₀ − x̄)²; the interval for the mean shrinks towards 0 with more data, the prediction interval never below about ±t* × s.
  • Extrapolation, beyond the data’s x or to conditions the sample didn’t cover, is outside what any interval measures.
  • The prediction interval depends strongly on constant spread and roughly normal errors, at any sample size.
  • For planning against one costly side, use a one-sided bound: ŷ₀ + T.INV(1 − α, n − 2) × SE_pred.

Key formulas

Terms introduced

Point prediction
The value of a fitted regression at a new x, ŷ₀ = b₀ + b₁x₀: the estimate of the mean response there and the best single guess for one new case.
Confidence interval for the mean response
An interval for the average of y over all cases with a given x, ŷ₀ ± t* × s√(1/n + (x₀ − x̄)²/Sxx) in simple regression. It narrows towards zero width as the sample grows.
Prediction interval
An interval for the value of y in one new case at a given x, ŷ₀ ± t* × s√(1 + 1/n + (x₀ − x̄)²/Sxx) in simple regression. Always wider than the interval for the mean, because it adds the new case’s own error.

Sources

  1. Penn State Eberly College of Science. STAT 462: Applied Regression Analysis, lesson 4.11, “Prediction Interval for a New Response”. online.stat.psu.edu/stat462/node/127
  2. Holmes, A., Illowsky, B. & Dean, S. (2023). Introductory Business Statistics 2e, section 13.6, “Predicting with a Regression Equation”. OpenStax. openstax.org/books/introductory-business-statistics/pages/13…
  3. Illowsky, B. & Dean, S. (2023). Introductory Statistics 2e, section 12.5, “Prediction”. OpenStax. openstax.org/books/introductory-statistics-2e/pages/12-5-pre…
  4. NIST/SEMATECH. e-Handbook of Statistical Methods, section 4.1.4.1, “Linear Least Squares Regression”. itl.nist.gov/div898/handbook/pmd/section1/pmd141.htm
  5. Microsoft Support. “FORECAST and FORECAST.LINEAR functions”. support.microsoft.com/en-us/excel/forecast-and-forecast-line…