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 the S draws: 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 equals irf() 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; banding irf() and then summing would instead sum quantiles, which is not a quantile of anything.

Parameters:
  • horizon (int) – Largest lead H to return; leads 0 .. H.

  • orthogonalized (bool) – Rotate each draw by its own lower Cholesky factor; see irf() for the identifying assumption this carries.

  • cumulative (bool) – Band the running sums over leads instead of the responses themselves.

Return type:

NDArray[double]

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 variable i at lead h to shock j.

Raises:

SpecificationError – If horizon is 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 growth to 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_draws and sigma_draws – for other quantiles, joint bands, or responses to a non-recursive rotation, propagate the draws yourself.