VARMAResult.ma_representation#

VARMAResult.ma_representation(horizon=20)[source]#

Moving-average matrices Psi_0, ..., Psi_horizon of the VARMA.

Computed by the recursion

\[\Psi_h = M_h + \sum_{i=1}^{\min(h, p)} A_i\, \Psi_{h-i}, \qquad M_h = 0 \;\text{ for } h > q,\]

which is the representation the impulse responses, variance decompositions, and historical decomposition inherited from the propagation surface all consume – overriding this one method is what makes every one of them correct for a VARMA.

Parameters:

horizon (int) – Largest lead to return.

Return type:

NDArray[double]

Returns:

An array of shape (horizon + 1, k, k); Psi_0 is the identity.

Raises:

SpecificationError – If horizon is negative.

Example

>>> 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()
>>> psi = res.ma_representation(3)
>>> psi.shape, bool(np.allclose(psi[0], np.eye(2)))
((4, 2, 2), True)
>>> bool(np.allclose(psi[2], res.coefficients[0] @ psi[1]))
True
>>> res.ma_representation(-1)
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: horizon must be non-negative; got -1.