## 5.5 Prediction intervals

As discussed in Section 1.7, a prediction interval gives an interval within which we expect $$y_{t}$$ to lie with a specified probability. For example, assuming that the residuals are normally distributed, a 95% prediction interval for the $$h$$-step forecast is $\hat{y}_{T+h|T} \pm 1.96 \hat\sigma_h,$ where $$\hat\sigma_h$$ is an estimate of the standard deviation of the $$h$$-step forecast distribution.

More generally, a prediction interval can be written as $\hat{y}_{T+h|T} \pm c \hat\sigma_h$ where the multiplier $$c$$ depends on the coverage probability. In this book we usually calculate 80% intervals and 95% intervals, although any percentage may be used. The following table gives the value of $$c$$ for a range of coverage probabilities assuming normally distributed residuals.

Table 5.1: Multipliers to be used for prediction intervals.
Percentage Multiplier
50 0.67
55 0.76
60 0.84
65 0.93
70 1.04
75 1.15
80 1.28
85 1.44
90 1.64
95 1.96
96 2.05
97 2.17
98 2.33
99 2.58

The value of prediction intervals is that they express the uncertainty in the forecasts. If we only produce point forecasts, there is no way of telling how accurate the forecasts are. However, if we also produce prediction intervals, then it is clear how much uncertainty is associated with each forecast. For this reason, point forecasts can be of almost no value without the accompanying prediction intervals.

### One-step prediction intervals

When forecasting one step ahead, the standard deviation of the forecast distribution is almost the same as the standard deviation of the residuals. (In fact, the two standard deviations are identical if there are no parameters to be estimated, as is the case with the naïve method. For forecasting methods involving parameters to be estimated, the standard deviation of the forecast distribution is slightly larger than the residual standard deviation, although this difference is often ignored.)

For example, consider a naïve forecast for the Google stock price data google_2015 (shown in Figure 5.3). The last value of the observed series is 758.88, so the forecast of the next value of the GSP is 758.88. The standard deviation of the residuals from the naïve method is 11.19. Hence, a 95% prediction interval for the next value of the GSP is $758.88 \pm 1.96(11.19) = [736.9, 780.8].$ Similarly, an 80% prediction interval is given by $758.88 \pm 1.28(11.19) = [744.5, 773.2].$

The value of the multiplier (1.96 or 1.28) is taken from Table 5.1.

### Multi-step prediction intervals

A common feature of prediction intervals is that they increase in length as the forecast horizon increases. The further ahead we forecast, the more uncertainty is associated with the forecast, and thus the wider the prediction intervals. That is, $$\sigma_h$$ usually increases with $$h$$ (although there are some non-linear forecasting methods that do not have this property).

To produce a prediction interval, it is necessary to have an estimate of $$\sigma_h$$. As already noted, for one-step forecasts ($$h=1$$), the residual standard deviation provides a good estimate of the forecast standard deviation $$\sigma_1$$. For multi-step forecasts, a more complicated method of calculation is required. These calculations assume that the residuals are uncorrelated.

### Benchmark methods

For the four benchmark methods, it is possible to mathematically derive the forecast standard deviation under the assumption of uncorrelated residuals. If $$\hat{\sigma}_h$$ denotes the standard deviation of the $$h$$-step forecast distribution, and $$\hat{\sigma}$$ is the residual standard deviation, then we can use the following expressions.

Mean forecasts: $$\hat\sigma_h = \hat\sigma\sqrt{1 + 1/T}$$

Naïve forecasts: $$\hat\sigma_h = \hat\sigma\sqrt{h}$$

Seasonal naïve forecasts $$\hat\sigma_h = \hat\sigma\sqrt{k+1}$$, where $$k$$ is the integer part of $$(h-1)/m$$.

Drift forecasts: $$\hat\sigma_h = \hat\sigma\sqrt{h(1+h/T)}$$.

Note that when $$h=1$$ and $$T$$ is large, these all give the same approximate value $$\hat\sigma$$.

Prediction intervals can easily be computed for you when using the fable package. For example, here is the output when using the naïve method for the Google stock price.

The hilo() function converts the forecast distributions into intervals. By default, 80% and 95% prediction intervals are returned, although other options are possible via the level argument.

When plotted, the prediction intervals are shown as shaded region, with the strength of colour indicating the probability associated with the interval. Again, 80% and 95% intervals are shown by default, with other options available via the level argument.

### Prediction intervals from bootstrapped residuals

When a normal distribution for the residuals is an unreasonable assumption, one alternative is to use bootstrapping, which only assumes that the residuals are uncorrelated.

A one-step forecast error is defined as $$e_t = y_t - \hat{y}_{t|t-1}$$. We can re-write this as $y_t = \hat{y}_{t|t-1} + e_t.$ So we can simulate the next observation of a time series using $y_{T+1} = \hat{y}_{T+1|T} + e_{T+1}$ where $$\hat{y}_{T+1|T}$$ is the one-step forecast and $$e_{T+1}$$ is a unknown future error. Assuming future errors will be similar to past errors, we can replace $$e_{T+1}$$ by sampling from the collection of errors we have seen in the past (i.e., the residuals). Adding the new simulated observation to our data set, we can repeat the process to obtain $y_{T+2} = \hat{y}_{T+2|T+1} + e_{T+2}$ where $$e_{T+2}$$ is another draw from the collection of residuals. Continuing in this way, we can simulate an entire set of future values for our time series.

Doing this repeatedly, we obtain many possible futures. To see some of them, we can use the generate() function.

Here we have generated five possible sample paths for the next 30 trading days. The .rep variable provides a new key for the tsibble. The plot below shows the five sample paths along with the historical data.

Then we can compute prediction intervals by calculating percentiles of the future sample paths for each forecast horizon. The result is called a bootstrapped prediction interval. The name “bootstrap” is a reference to pulling ourselves up by our bootstraps, because the process allows us to measure future uncertainty by only using the historical data.

This is all built into the forecast() function so you do not need to call generate() directly.

Notice that the forecast distribution is now represented as a simulation with 5000 sample paths. Because there is no normality assumption, the prediction intervals are not symmetric.

The number of samples can be controlled using the times argument for forecast(). For example, intervals based on 1000 bootstrap samples can be sampled with:

In this case, they are similar (but not identical) to the prediction intervals based on the normal distribution.

Use the slider below to see the effect of varying the number of bootstrap samples (times) on the forecast distribution: