GraphicalVARResult.ma_representation#

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

Moving-average matrices of the fitted system.

\(\Psi_0 = I\) and \(\Psi_h = \sum_{i=1}^{\min(h, p)} A_i \Psi_{h-i}\), the response of \(y_{t+h}\) to a unit reduced-form innovation at \(t\).

Parameters:

horizon (int) – Largest lead to return.

Return type:

NDArray[double]

Returns:

An array of shape (horizon + 1, k, k) with Psi_0 = I.

Raises:

SpecificationError – If horizon is negative.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.zeros((200, 3))
>>> for t in range(1, 200):
...     y[t] = 0.5 * y[t - 1] + rng.standard_normal(3)
>>> res = SparseVAR(y, order=1).fit(penalty="lasso")
>>> psi = res.ma_representation(4)
>>> psi.shape, bool(np.array_equal(psi[0], np.eye(3)))
((5, 3, 3), True)
>>> bool(np.allclose(psi[3], np.linalg.matrix_power(res.coefficients[0], 3)))
True
>>> res.ma_representation(-1)
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: horizon must be non-negative; got -1.