Spillover.compute#
- Spillover.compute()[source]#
Read the connectedness table off the generalized decomposition.
Forms \(\Psi_h \Sigma_u e_j / \sqrt{\sigma_{jj}}\) for every lead and every shock, cumulates the squares over \(h = 0, \ldots, H\), normalizes each row to 100 and reads the directional sums off the off-diagonal.
- Return type:
- Returns:
The
SpilloverResult, all entries in percent.
Example
The table agrees with the VAR result’s own generalized decomposition at the same horizon, and connectedness grows with the horizon as shocks propagate:
>>> import numpy as np >>> from cultivars.multivariate.reduced_form.vector_autoregression import VAR >>> rng = np.random.default_rng(0) >>> y = np.zeros((300, 3)) >>> a = np.array([[0.5, 0.3, 0.0], [0.0, 0.5, 0.0], [0.0, 0.0, 0.5]]) >>> for t in range(1, 300): ... y[t] = a @ y[t - 1] + rng.standard_normal(3) >>> fit = VAR(y, order=1).fit() >>> spill = Spillover(fit, horizon=10).compute() >>> bool(np.allclose(spill.table, 100.0 * fit.generalized_fevd(10)[-1])) True >>> short = Spillover(fit, horizon=1).compute() >>> bool(short.total < spill.total) True