VARMAResult.forecast#
- VARMAResult.forecast(steps=1)[source]#
Deterministic multi-step forecasts from the end of the sample.
The moving-average block contributes only while a forecast date is within
qperiods of the sample: the innovations after the sample end are set to their zero mean, and the lastqestimated innovations decay out of the forecast one step at a time,\[\hat y_{T+h} = D d_{T+h} + \sum_{i=1}^{p} A_i\, \hat y_{T+h-i} + \sum_{j=h+1}^{q} M_j\, \hat u_{T+h-j}.\]Beyond
qsteps the iteration is exactly the autoregressive one.- Parameters:
steps (
int) – Forecast horizon, at least one.- Return type:
- Returns:
An array of shape
(steps, k).- Raises:
SpecificationError – If
stepsis less than one.
Example
The first step carries the last innovation through
M_1; the second is the pure autoregressive iteration of the first:>>> import numpy as np >>> rng = np.random.default_rng(0) >>> u = rng.standard_normal((302, 2)) >>> y = np.zeros((302, 2)) >>> for t in range(1, 302): ... y[t] = 0.5 * y[t - 1] + u[t] + 0.4 * u[t - 1] >>> res = VARMA(y[2:], order=(1, 1)).fit() >>> path = res.forecast(2) >>> first = res.deterministic[0] + res.coefficients[0] @ y[-1] >>> first = first + res.ma_coefficients[0] @ res.resid[-1] >>> bool(np.allclose(path[0], first)) True >>> bool(np.allclose(path[1], res.deterministic[0] + res.coefficients[0] @ path[0])) True >>> res.forecast(0) Traceback (most recent call last): cultivars.exceptions.SpecificationError: steps must be at least 1; got 0.