HierarchicalBVARResult.irf#

HierarchicalBVARResult.irf(horizon=20, *, orthogonalized=True, cumulative=False)[source]#

Posterior mean impulse responses.

The moving-average representation of the system writes each observation as a sum of current and past innovations,

\[y_t = \text{deterministic} + \sum_{h=0}^{\infty} \Psi_h\, u_{t-h}, \qquad \Psi_0 = I_k, \quad \Psi_h = \sum_{l=1}^{\min(h, p)} \Psi_{h-l} A_l,\]

so \(\Psi_h\) is the response of the system at lead h to a unit innovation. Innovations are correlated across equations, so a unit innovation in one is not an interpretable experiment; the orthogonalized responses \(\Theta_h = \Psi_h P\), with \(P\) the lower Cholesky factor of \(\Sigma\), are the responses to one-standard-deviation structural shocks under the recursive identification in which each variable responds contemporaneously only to shocks ordered before it.

This method returns the posterior mean of that object,

\[\mathbb{E}[\Theta_h \mid Y] \approx \frac{1}{S} \sum_{s=1}^{S} \Psi_h(B^{(s)})\, P(\Sigma^{(s)}),\]

computed draw by draw: each draw’s own coefficients and its own Cholesky factor, then the average. This is not the response of the posterior mean coefficients, \(\Psi_h(\bar B)\), because \(\Psi_h\) is a degree-h polynomial in the lag matrices and the mean of a polynomial is not the polynomial of the mean; the two coincide only at lead zero and lead one. The difference grows with the lead and with posterior dispersion, so it is largest exactly where a loosely shrunk system is least informative.

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

  • orthogonalized (bool) – Rotate each draw by its own lower Cholesky factor so that shocks are orthogonal, one-standard-deviation structural shocks in the order of names. False returns responses to unit reduced-form innovations, \(\Psi_h\), which do not depend on the ordering.

  • cumulative (bool) – Return running sums over leads, \(\sum_{g \le h} \Theta_g\), the response of the level when the modelled series are differences.

Return type:

NDArray[double]

Returns:

An array of shape (horizon + 1, k, k); entry [h, i, j] is the posterior mean response of variable i at lead h to shock j. Lead zero is \(I_k\) when not orthogonalized and the posterior mean Cholesky factor, lower-triangular, when it is.

Raises:

SpecificationError – If horizon is negative.

Warning

With orthogonalized=True the column order of endog is an identifying assumption, exactly as in RecursiveSVAR: shock j moves variables j, j + 1, ... on impact and variables before j only from lead one. Reorder the columns before fitting to assert a different causal ordering; there is no reordering argument here because the posterior draws are already conditioned on the fitted layout.

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)
>>> res.irf(8).shape
(9, 2, 2)

Lead zero is the identity for reduced-form responses and a lower-triangular factor for orthogonalized ones, so the first variable does not respond on impact to the second shock:

>>> np.allclose(res.irf(8, orthogonalized=False)[0], np.eye(2))
True
>>> float(res.irf(8)[0, 0, 1])
0.0

Cumulative responses are running sums:

>>> np.allclose(res.irf(8, cumulative=True)[-1], res.irf(8).sum(axis=0))
True

The posterior mean response is not the response at the posterior mean beyond lead one:

>>> at_mean = np.linalg.matrix_power(res.coefficients[0], 2)
>>> np.allclose(res.irf(2, orthogonalized=False)[2], at_mean)
False

See also

  • irf_bands() – the same responses with their 68% posterior bands.

  • RecursiveSVAR – the same recursive identification on a point-estimated VAR.

  • SignRestrictedSVAR – set identification when no recursive ordering is credible.

References

Sims, C. A. (1980). Macroeconomics and reality. Econometrica, 48(1), 1-48.

Lütkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. Springer. Chapters 2 and 3.

Koop, G., & Korobilis, D. (2010). Bayesian multivariate time series methods for empirical macroeconomics. Foundations and Trends in Econometrics, 3(4), 267-358.