QVARResult.ma_representation#

QVARResult.ma_representation(horizon=20, *, quantile)[source]#

Moving-average matrices of one level’s coefficient stack.

The companion powers of coefficients(quantile) read back into (k, k) blocks – the linear propagation the level’s system would have if it were a law of motion.

Parameters:
  • horizon (int) – Largest lead to return.

  • quantile (float) – An estimated level.

Return type:

NDArray[double]

Returns:

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

Raises:

SpecificationError – If horizon is negative or the level was not estimated.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.zeros((300, 2))
>>> for t in range(1, 300):
...     y[t] = 0.5 * y[t - 1] + rng.standard_normal(2)
>>> res = QVAR(y, order=1).fit(quantiles=(0.5,))
>>> psi = res.ma_representation(3, quantile=0.5)
>>> psi.shape, bool(np.allclose(psi[0], np.eye(2)))
((4, 2, 2), True)
>>> bool(np.allclose(psi[1], res.coefficients(0.5)[0]))
True
>>> bool(np.allclose(psi[2], psi[1] @ psi[1]))
True
>>> res.ma_representation(-1, quantile=0.5)
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: horizon must be non-negative; got -1.