ECON 310 · Econometrics I

Forecasting With Regression

A fitted line can predict the future, but an honest forecast comes with a range, and the range widens the further you stray.

Key takeaways

  • A regression forecast plugs a new value of x into the fitted line to get a predicted y.
  • A forecast is a range, not a single number: a prediction interval says where an actual outcome is likely to land.
  • A prediction interval is wider than a confidence interval for the average, because one real outcome carries its own random error.
  • The farther x is from the middle of the data, the wider the interval.
  • A model that fits the past beautifully can still forecast poorly; test it on data it was not fitted to.

Sam owns an ice cream shop and has a problem every Friday: how much ice cream to order for the weekend. Order too little and the line of customers leaves disappointed. Order too much and the extra melts into an expensive puddle. The weather forecast says 80 degrees. Sam has a year of records of temperature and sales. What should be ordered?

This is a forecasting problem, and regression is one of the oldest tools for it. You fit a line to past data, then feed it a new x and read off a predicted y. Simple. But the part that separates a careful forecaster from a lucky guesser is what comes next: how wrong might the prediction be, and why?

In this lesson you will learn to produce a forecast, put a range around it, tell two kinds of intervals apart, and check whether a model forecasts well on data it has never seen.

From a fitted line to a forecast

Suppose Sam's records of 25 weeks give this fitted line, where weekly sales are measured in hundreds of dollars and temperature in degrees Fahrenheit:

sales = −10 + 0.8 × temperature

These numbers are made up to show the method. The slope says each extra degree goes with $80 more sales (0.8 hundreds). The average temperature in the sample is 70°F, and at 70 the line gives −10 + 0.8 × 70 = 46, or $4,600 a week. Every fitted line passes through the point of averages, so 46 is also the average weekly sales in this data.

Now the weather report says 80°F. Plug it in:

sales = −10 + 0.8 × 80 = −10 + 64 = 54

A forecast of $5,400. That is the point forecast, a single best guess. Sam can order on that number, but a good manager asks: how sure are we?

Why a forecast is never exact

Even if Sam knew the true line perfectly, sales would not land exactly on it. Some weeks a school trip stops by, some weeks it rains, some weeks the machine breaks. Those leftover influences are the disturbance term from the classical assumptions. They never go away.

On top of that, Sam does not know the true line. The slope and intercept were estimated from only 25 weeks, so they carry the uncertainty described in the inference lesson.

So a forecast error has two sources:

  1. The unavoidable noise in a single week's sales.
  2. The estimation error in the fitted line.

The second shrinks with more data. The first does not. That is why the interval for a single outcome stays wide however large your sample.

The residual standard error, often written s, measures the typical size of the first. Say Sam's regression reports s = 4, meaning a typical week misses the line by about 4 hundred dollars.

Two intervals, two questions

It helps to know that the same x can come with two different ranges, and they answer different questions.

  • A confidence interval for the mean answers: "On average across many 80-degree weeks, where do sales sit?" It reflects only the uncertainty in the line.
  • A prediction interval answers: "Where will this particular 80-degree weekend land?" It adds the week-to-week noise on top.

Sam cares about this weekend, so the prediction interval is the right tool. The formula for its width includes everything above:

How wide is a forecast range?
Range = t × s × Stretch factor Range = Plus or minus Forecast ± this amount. t × s = Critical value times noise t is about 2 for a 95% range; s is the residual standard error. Stretch factor = √[1 + 1÷n + (x₀ − x̄)² ÷ Sxx] Grows as the new x₀ moves away from the average x̄. Range = t × s × Stretch factor Range = Plus or minus Forecast ± this amount. t × s = Critical value times noise t is about 2 for a 95% range; s is the residual standard error. Stretch factor = √[1 + 1÷n + (x₀ − x̄)² ÷ Sxx] Grows as the new x₀ moves away from the average x̄.

The 1 inside the brackets is the unavoidable noise of a single outcome. The other two pieces are the line's own uncertainty.

Here n is the number of observations, x₀ is the new x you are forecasting for, x̄ is the average x in the data, and Sxx is the total squared spread of x. The critical value t depends on sample size: for 23 degrees of freedom (n − 2 with n = 25) and 95% coverage it is about 2.07.

A fully worked example

Sam's data: n = 25, s = 4, average temperature 70, and Sxx = 2,400.

Forecast for 80°F. The forecast is 54. The stretch factor has three pieces:

1                  = 1.0000
1 ÷ n = 1 ÷ 25      = 0.0400
(80 − 70)² ÷ 2,400 = 100 ÷ 2,400 = 0.0417
total              = 1.0817
square root        ≈ 1.040

The range is t × s × 1.040 = 2.07 × 4 × 1.040 ≈ 8.6. The 95% prediction interval is 54 ± 8.6, or about 45.4 to 62.6. In dollars: roughly $4,540 to $6,260.

Compare with the interval for the mean. Drop the "1" inside the brackets:

0.0400 + 0.0417 = 0.0817, square root ≈ 0.286
range = 2.07 × 4 × 0.286 ≈ 2.4

The average across many 80-degree weeks sits within 54 ± 2.4, or 51.6 to 56.4. Much narrower, and a different question.

Forecast for 100°F. The new x is far from the average of 70. The line gives −10 + 0.8 × 100 = 70.

1 + 0.0400 + (100 − 70)² ÷ 2,400
= 1 + 0.0400 + 900 ÷ 2,400
= 1 + 0.0400 + 0.3750 = 1.4150
square root ≈ 1.190
range = 2.07 × 4 × 1.190 ≈ 9.8

The prediction interval is 70 ± 9.8, or about 60.2 to 79.8. It is wider than at 80°F. The same thing happens below average: at 40°F the gap from the average is also 30, so the width is again ±9.8.

The forecast range fans out away from the middle
Weekly sales ($ hundreds) 80 54 Fitted line Upper 95% range Lower 95% range Forecast Temperature (°F) Weekly sales ($ hundreds) 80 54 Fitted line Upper 95% range Lower 95% range Forecast Temperature (°F)

The dashed band is narrowest at the average temperature of 70 and widens on both sides.

Forecasting x too

In Sam's example, the weather report supplies 80°F. In many economic forecasts you do not have next year's x; you must forecast it first. If you want to predict consumer spending next year using income, you need a forecast of income. Any error in the forecast of x carries into the forecast of y. This is called a conditional forecast when it is stated as "if income is X, spending will be Y," and it is honest about the dependence.

Official forecasts from central banks and government agencies are often stated with a range or scenarios for exactly this reason. To see what the Federal Reserve, the Congressional Budget Office or the Bureau of Economic Analysis currently publish, go to their own sites; numbers change often.

Does the model forecast well? Test it out of sample

A model's fit to old data is flattering. Add enough variables and the in-sample fit always improves, as we saw in choosing which variables to include. A model with 20 variables for 25 weeks can match the past almost perfectly and forecast the future terribly. This is overfitting: the model learned the quirks of the old data, not the lasting pattern.

The fix is to hide some data. Fit the model on the earlier part, then forecast the held-back part and compare. This is called out-of-sample testing.

Suppose Sam fits on weeks 1 to 21 and then forecasts the last four weeks:

Week Forecast Actual Error (actual − forecast)
22 48 50 +2
23 52 49 −3
24 60 64 +4
25 44 43 −1

Two common summaries:

  • Mean absolute error (MAE): ignore signs and average. (2 + 3 + 4 + 1) ÷ 4 = 10 ÷ 4 = 2.5.
  • Root mean squared error (RMSE): square each error, average, then take the square root. Squares: 4, 9, 16, 1, which add to 30. Divide by 4 for 7.5. The square root is about 2.74.

RMSE punishes big misses more than MAE does. Compare it with the model's in-sample s of 4: here the out-of-sample misses (RMSE 2.74) are no worse than the model claims, which is good news, though four weeks is a very small test.

Note also that time-ordered data bring their own hazard. If errors in one week tend to be followed by errors in the same direction the next week, as in autocorrelation, the forecast interval above is too narrow, and a simple regression leaves useful information on the table.

Common mistakes

  1. Reporting only the point forecast. A single number hides the uncertainty and invites false confidence.
  2. Using the confidence interval for the mean when forecasting one outcome. It is far too narrow for a single case.
  3. Extrapolating far beyond the data. The line was fitted for temperatures from about 40 to 100. At 130°F nothing says the same line holds, and the interval is wide anyway. Ice cream does not sell forever as the weather heats up.
  4. Trusting a model because it fits the past. In-sample fit is cheap. Test on data the model has not seen.
  5. Ignoring a regime change. If something fundamental shifts, such as a competitor opening next door, the old relationship may break. Economists call this a structural break.
A forecasting routine you can trust
1 Fit on the past Estimate the line using one part of the data. 2 Test on hidden data Forecast data the model has not seen; compute MAE or RMSE. 3 Forecast with a range Report the point forecast plus a prediction interval. 4 Check and refit Compare against what happens, and update the model. Fit on the past Estimate the line using one part of the data. 1 Test on hidden data Forecast data the model has not seen; compute MAE or RMSE. 2 Forecast with a range Report the point forecast plus a prediction interval. 3 Check and refit Compare against what happens, and update the model. 4

The routine repeats whenever new data arrive.

Words to know

Point forecast the single best-guess value of y for a new x, read from the fitted line.

Prediction interval a range that is likely to contain the actual outcome for one new observation.

Confidence interval for the mean a range for the average outcome at a given x, narrower than a prediction interval.

Out-of-sample test judging a model by how well it forecasts data that were held back from fitting.

RMSE the square root of the average squared forecast error, a standard measure of typical miss size.

Overfitting building a model so closely tuned to past data that it forecasts new data poorly.

Structural break a lasting change in the relationship between variables that makes old estimates unreliable.

Check yourself

  1. With sales = −10 + 0.8 × temperature, what is the point forecast at 90°F?
  2. Why is a prediction interval wider than a confidence interval for the mean at the same x?
  3. At x₀ = 80, the stretch factor is √1.0817 ≈ 1.040. Using t = 2.07 and s = 4, compute the width of the 95% prediction interval on each side.
  4. Why is the interval at 100°F wider than at 80°F?
  5. Out-of-sample errors are +2, −3, +4 and −1. Compute the mean absolute error and the RMSE.
  6. Explain overfitting, and say why a model with a great in-sample fit might still forecast poorly.
Show the answers
  1. −10 + 0.8 × 90 = −10 + 72 = 62, which is $6,200.
  2. It adds the unavoidable noise of one real outcome, the "1" inside the square root, on top of the uncertainty in the fitted line.
  3. 2.07 × 4 × 1.040 ≈ 8.6 hundred dollars, so the interval is the forecast ± 8.6.
  4. The term (x₀ − x̄)² ÷ Sxx grows as x₀ moves away from the average temperature (0.375 at 100 versus 0.042 at 80), so the line is less certain there.
  5. MAE = (2 + 3 + 4 + 1) ÷ 4 = 2.5; RMSE = √[(4 + 9 + 16 + 1) ÷ 4] = √7.5 ≈ 2.74.
  6. Overfitting means the model has learned quirks and noise in the old data rather than the lasting pattern, so it matches the past almost perfectly yet misses on new data.

A free self-study program written for 4Economics with AI writing tools and not reviewed line by line by a person. It is not an accredited degree and awards no credit. Check anything you rely on against a textbook or primary source. Report an error.

In this unit: When assumptions fail

  1. MulticollinearityFind out what happens when explanatory variables move together, why standard errors balloon, and what to do about it.10 min
  2. Heteroskedasticity and Robust Standard ErrorsLearn why uneven scatter around a regression line makes ordinary standard errors unreliable, and how robust errors fix them.11 min
  3. Autocorrelation in Time SeriesSee how errors that carry over from one period to the next make standard errors too small, and how to detect and fix it.10 min
  4. Measurement ErrorWhen the numbers in your data are blurry copies of what you care about, regression slopes shrink toward zero.12 min
  5. Simultaneity and Reverse CausationWhen x affects y and y also affects x, a plain regression mixes the two effects and can even get the sign wrong.11 min
  6. Outliers, Influence and Residual ChecksOne odd data point can swing a regression line; learn to spot it, measure its pull, and decide what to do.10 min
  7. Linear Probability, Logit and Probit ModelsWhen the outcome is yes or no, a straight line can predict impossible probabilities; logit and probit bend the line to fit.10 min
  8. Forecasting With RegressionA fitted line can predict the future, but an honest forecast comes with a range, and the range widens the further you stray.9 min
  9. Reading a Regression Table in a Research PaperLearn to read the grid of coefficients, standard errors and stars that sits at the heart of every empirical paper.10 min

In the news