HierarchicalBVARResult.irf_bands#
- HierarchicalBVARResult.irf_bands(horizon=20, *, orthogonalized=True, cumulative=False)[source]#
Posterior bands of the impulse responses.
The same draw-by-draw responses as
irf(), summarized at every[h, i, j]by the 16th percentile, mean, and 84th percentile across theSdraws: a pointwise 68% central credible band, one standard deviation wide under normality. Pointwise means each(h, i, j)cell is banded on its own; the band is not a joint region over leads, so a path that stays inside it at every lead is not thereby a posterior-probable path. The middle slice equalsirf()with the same arguments.With
cumulative, the running sums are formed draw by draw first and the quantiles taken of those, which is the posterior of the cumulative response; bandingirf()and then summing would instead sum quantiles, which is not a quantile of anything.- Parameters:
- Return type:
- Returns:
An array of shape
(horizon + 1, k, k, 3)whose last axis is(16th percentile, mean, 84th percentile)across draws; entry[h, i, j, :]summarizes the response of variableiat leadhto shockj.- Raises:
SpecificationError – If
horizonis negative.
Example
>>> import numpy as np >>> from cultivars.multivariate.large_dim.bayesian import BVAR >>> rng = np.random.default_rng(0) >>> y = np.zeros((120, 2)) >>> for t in range(1, 120): ... y[t] = 0.7 * y[t - 1] + rng.standard_normal(2) >>> res = BVAR(y, order=1, names=("growth", "inflation")).fit(n_draws=200, seed=0) >>> bands = res.irf_bands(8) >>> bands.shape (9, 2, 2, 3) >>> bool((bands[..., 0] <= bands[..., 1]).all()) True >>> bool((bands[..., 1] <= bands[..., 2]).all()) True >>> np.allclose(bands[..., 1], res.irf(8)) True
The own response of
growthto its own shock, lead by lead, as(low, mean, high)rows:>>> bands[:3, 0, 0, :].shape (3, 3)
See also
irf()– the posterior mean alone.beta_drawsandsigma_draws– for other quantiles, joint bands, or responses to a non-recursive rotation, propagate the draws yourself.