Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

A common objective of time series modeling is generating forecasts for a process
over a future time horizon. That is, given an observed series
*y*_{1},
*y*_{2},...,*y _{N}*
and a forecast horizon

Let $${\widehat{y}}_{t+1}$$ denote a forecast for the process at time *t* +
1, conditional on the history of the process up to time *t*,
*H _{t}*, and the exogenous covariate
series up to time

$$E{\left({y}_{t+1}-{\widehat{y}}_{t+1}|{H}_{t},{X}_{t+1}\right)}^{2}.$$

Minimizing this loss function yields the MMSE forecast,

$${\widehat{y}}_{t+1}=E({y}_{t+1}|{H}_{t},{X}_{t+1}).$$

`forecast`

Generates MMSE ForecastsThe `forecast`

function generates MMSE forecasts recursively.
When you call `forecast`

, you specify the model
`Mdl`

, forecast horizon `numperiods`

, and
presample responses `Y0`

. You can optionally specify the presample
innovations `'E0'`

, conditional variances `'V0'`

,
and exogenous data `'X0'`

by using name-value pair arguments.
Although `forecast`

does not require `X0`

or
forecast sample exogenous data `XF`

, if you specify
`X0`

then you must also specify `XF`

.

To begin forecasting from the end of an observed series, say `Y`

,
use the last few observations of `Y`

as presample responses
`Y0`

to initialize the forecast. There are several points to
keep in mind when you specify presample data:

The minimum number of responses needed to initialize forecasting is stored in the property

`P`

of an`arima`

model. If you provide too few presample observations,`forecast`

returns an error.If you forecast a model with an MA component, then

`forecast`

requires presample innovations. The number of innovations needed is stored in the property`Q`

of an`arima`

model. If you also have a conditional variance model, you must additionally account for any presample innovations it requires. If you specify presample innovations, but not enough,`forecast`

returns an error.If you do not specify any presample innovations, but specify sufficient presample

*responses*(at least`P`

+`Q`

) and exogenous covariate data (at least the number of presample responses minus`P`

), then`forecast`

automatically infers presample innovations. In general, the longer the presample response series you provide, the better the inferred presample innovations will be. If you provide presample responses and exogenous covariate data, but not enough,`forecast`

sets presample innovations equal to zero.If you forecast a model with a regression component, then

`forecast`

requires future exogenous covariate data for all time points in the forecast period (`numperiods`

). If you provide future exogenous covariate data, but not enough, then`forecast`

returns an error.

Consider generating forecasts for an AR(2) process,

$${y}_{t}=c+{\varphi}_{1}{y}_{t-1}+{\varphi}_{2}{y}_{t-2}+{\epsilon}_{t}.$$

Given presample observations $${y}_{N-1}$$ and $${y}_{N},$$ forecasts are recursively generated as follows:

$${\widehat{y}}_{N+1}=c+{\varphi}_{1}{y}_{N}+{\varphi}_{2}{y}_{N-1}$$

$${\widehat{y}}_{N+2}=c+{\varphi}_{1}{\widehat{y}}_{N+1}+{\varphi}_{2}{y}_{N}$$

$${\widehat{y}}_{N+3}=c+{\varphi}_{1}{\widehat{y}}_{N+2}+{\varphi}_{2}{\widehat{y}}_{N+1}$$

$$\vdots $$

For a stationary AR process, this recursion converges to the unconditional mean of the process,

$$\mu =\frac{c}{\left(1-{\varphi}_{1}-{\varphi}_{2}\right)}.$$

For an MA(2) process, e.g.,

$${y}_{t}=\mu +{\epsilon}_{t}+{\theta}_{1}{\epsilon}_{t-1}+{\theta}_{2}{\epsilon}_{t-2},$$

you need 2 presample innovations to initialize the forecasts. All
innovations from time *N* + 1 and greater are set to their
expectation, zero. Thus, for an MA(2) process, the forecast for any time more than 2
steps in the future is the unconditional mean, *μ*.

The forecast mean square error for an *s*-step ahead forecast is
given by

$$\text{MSE}=E{\left({y}_{t+s}-{\widehat{y}}_{t+s}|{H}_{t+s-1},{X}_{t+s}\right)}^{2}.$$

Consider a conditional mean model given by

$${y}_{t}=\mu +{x}_{t}^{\prime}\beta +\psi (L){\epsilon}_{t},$$

where $$\psi (L)=1+{\psi}_{1}L+{\psi}_{2}{L}^{2}+\dots $$. Sum the variances of the lagged innovations to get the
*s*-step MSE,

$$(1+{\psi}_{1}^{2}+{\psi}_{2}^{2}+\dots +{\psi}_{s-1}^{2}){\sigma}_{\epsilon}^{2},$$

where $${\sigma}_{\epsilon}^{2}$$ denotes the innovation variance.

For stationary processes, the coefficients of the infinite lag operator polynomial are absolutely summable, and the MSE converges to the unconditional variance of the process.

For nonstationary processes, the series does not converge, and the forecast error grows over time.