MarkovSwitchingSVARResult.irf#

MarkovSwitchingSVARResult.irf(horizon=20, *, regime, cumulative=False)[source]#

Structural impulse responses within one regime, held frozen.

Freezing the regime is the same linearization it is for the observed-regime families, with the latent twist stated plainly: the response assumes the chain stays in this regime over the horizon, so read it against that regime’s expected duration – a 20-period response in a regime that lasts 5 is an extrapolation.

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

  • regime (int) – Which regime’s identified system to propagate.

  • cumulative (bool) – Return running sums.

Return type:

NDArray[double]

Returns:

An array of shape (horizon + 1, k, s); entry [h, i, j] is the response of variable i at lead h to identified shock j, in that regime.

Raises:

SpecificationError – If regime is out of range.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> s = np.repeat([0, 1, 0, 1], 100)
>>> y = np.array([[-1.0, -0.5], [1.5, 1.0]])[s] + 0.4 * rng.standard_normal((400, 2))
>>> res = MarkovSwitchingVAR(y, order=1, n_regimes=2).fit(seed=0)
>>> svar = MarkovSwitchingSVAR(res).identify()
>>> plain, running = svar.irf(3, regime=0), svar.irf(3, regime=0, cumulative=True)
>>> plain.shape, bool(np.allclose(plain[0], svar.impact(0)))
((4, 2, 2), True)
>>> bool(np.allclose(running, np.cumsum(plain, axis=0)))
True