DFMResult.forecast#

DFMResult.forecast(steps=8)[source]#

Forecast the whole panel through the factor VAR.

The factors are forecast by their own fitted system and mapped back through the loadings; the idiosyncratic components are forecast at their zero mean, which is the model’s own claim about them. The forecasts therefore decay toward the series means at the factor VAR’s rate and carry no idiosyncratic persistence.

Parameters:

steps (int) – Horizons ahead, at least one.

Return type:

NDArray[double]

Returns:

An array of shape (steps, n_series) in original units.

Raises:

SpecificationError – If steps is not positive.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> f = np.zeros((200, 1))
>>> for t in range(1, 200):
...     f[t] = 0.8 * f[t - 1] + rng.standard_normal()
>>> panel = 5.0 + f @ rng.standard_normal((1, 6)) + 0.5 * rng.standard_normal((200, 6))
>>> res = DFM(panel, order=1, n_factors=1).fit()
>>> path = res.forecast(12)
>>> path.shape
(12, 6)
>>> gap = np.abs(path - res.means).max(axis=1)
>>> bool(gap[-1] < gap[0])
True
>>> res.forecast(0)
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: steps must be at least 1; got 0.