TVPSVARResult.irf#

TVPSVARResult.irf(horizon=20, *, t, cumulative=False)[source]#

Structural impulse responses at date t, held frozen.

The same linearization every regime family declares, in its drifting form: coefficients and impact are frozen at date t’s posterior mean, so the response reads “the transmission mechanism prevailing at t”, exact only while the parameters do not drift over the horizon – and a posterior-mean plug-in besides, with the path uncertainty available in the source’s retained draws.

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

  • t (int) – Date whose prevailing dynamics to propagate.

  • cumulative (bool) – Return running sums.

Return type:

NDArray[double]

Returns:

An array of shape (horizon + 1, k, k); entry [h, i, j] is the response of variable i at lead h to structural shock j, as of date t.

Raises:

SpecificationError – If horizon is negative or t out of range.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.zeros((140, 2))
>>> for t in range(1, 140):
...     y[t] = 0.5 * y[t - 1] + rng.standard_normal(2)
>>> source = TVPVAR(y, order=1, training=40).fit(n_draws=40, n_burn=15, seed=0)
>>> svar = TVPSVAR(source).identify()
>>> response = svar.irf(4, t=50)
>>> response.shape, bool(np.allclose(response[0], svar.impact(50)))
((5, 2, 2), True)
>>> expected = source.coefficients_at(50)[0] @ svar.impact(50)
>>> bool(np.allclose(response[1], expected))
True
>>> bool(np.allclose(svar.irf(4, t=50, cumulative=True)[-1], response.sum(axis=0)))
True
>>> svar.irf(-1, t=0)
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: horizon must be non-negative; got -1.