VARXResult.forecast#

VARXResult.forecast(steps=1, *, exog_future=None)[source]#

Point forecasts conditional on a future path for the exogenous block.

Iterates the fitted system forward with future innovations at their zero mean, the deterministic terms extrapolated, and the exogenous block read from exog_future for the horizon and from the last s sample rows for the lags that reach back into the sample.

Parameters:
  • steps (int) – Horizon, at least one.

  • exog_future (ArrayLike | None) – A (steps, m) path for the exogenous variables, in the column order of exog_names. Required.

Return type:

NDArray[double]

Returns:

A (steps, k) array of conditional means.

Raises:

Example

The two-step forecast is the fitted equation iterated by hand:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y, x = rng.standard_normal((120, 2)), rng.standard_normal((120, 1))
>>> res = VARX(y, x, order=1, exog_order=1).fit()
>>> future = np.array([[0.5], [-0.2]])
>>> A, B0, B1, c = res.coefficients[0], *res.exog_coefficients, res.deterministic[0]
>>> h0 = c + A @ y[-1] + B0 @ future[0] + B1 @ x[-1]
>>> h1 = c + A @ h0 + B0 @ future[1] + B1 @ future[0]
>>> bool(np.allclose(res.forecast(2, exog_future=future), np.vstack([h0, h1])))
True
>>> res.forecast(2, exog_future=np.zeros((3, 1)))
Traceback (most recent call last):
cultivars.exceptions.DimensionError: exog_future has 3 rows but the endogenous ...
>>> res.forecast(2, exog_future=np.zeros((2, 2)))
Traceback (most recent call last):
cultivars.exceptions.DimensionError: exog_future has 2 columns but the model was ...