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:
- Return type:
- Returns:
An array of shape
(horizon + 1, k, k); entry[h, i, j]is the response of variableiat leadhto structural shockj, as of datet.- Raises:
SpecificationError – If
horizonis negative ortout 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.