BVARResult._irf_draws#
- BVARResult._irf_draws(horizon, *, orthogonalized)[source]#
Impulse responses of every retained draw,
(S, horizon + 1, k, k).The shared engine behind
irf()andirf_bands(). For each draw it builds the companion matrix \(F^{(s)}\) from_stack_of()and reads the moving-average coefficients off its powers, \(\Psi_h^{(s)} = J (F^{(s)})^h J^\top\) with \(J = [I_k\ 0\ \cdots\ 0]\), accumulating the power one multiplication per lead rather than recomputing it. Whenorthogonalizedit post-multiplies every lead by the draw’s own lower Cholesky factor, \(\Theta_h^{(s)} = \Psi_h^{(s)} P^{(s)}\) with \(\Sigma^{(s)} = P^{(s)} P^{(s)\top}\). Withorderzero the responses are the identity at lead zero and zero after, before any rotation.Cost is \(O(S \cdot H \cdot (kp)^3)\) from the companion powers and \(O(S \cdot k^3)\) from the Cholesky factors, with the whole
(S, H + 1, k, k)array held in memory. Callers summarize across the draw axis; nothing is cached, soirf()andirf_bands()with the same arguments each recompute it.- Parameters:
- Return type:
- Returns:
A
(S, horizon + 1, k, k)array; entry[s, h, i, j]is draws’s response of variableiat leadhto shockj.- Raises:
SpecificationError – If
horizonis negative.
Example
>>> import numpy as np >>> from cultivars.multivariate.large_dim.bayesian import BVAR >>> y = np.random.default_rng(0).standard_normal((60, 2)) >>> res = BVAR(y, order=1).fit(n_draws=10, seed=0) >>> draws = res._irf_draws(3, orthogonalized=False) >>> draws.shape (10, 4, 2, 2) >>> np.allclose(draws[:, 0], np.eye(2)) True