SpectralCausalityResult.pair#
- SpectralCausalityResult.pair(cause, effect)[source]#
One directed pair’s measure across the grid.
- Parameters:
- Return type:
- Returns:
The
(n,)non-negative measure.- Raises:
SpecificationError – If either label is unknown.
Example
>>> import numpy as np >>> from cultivars.multivariate.reduced_form.vector_autoregression import VAR >>> rng = np.random.default_rng(0) >>> y = np.zeros((500, 2)) >>> for t in range(1, 500): ... y[t, 0] = 0.5 * y[t - 1, 0] + 0.4 * y[t - 1, 1] + rng.standard_normal() ... y[t, 1] = 0.5 * y[t - 1, 1] + rng.standard_normal() >>> res = VAR(y, order=1, names=("gdp", "rate")).fit() >>> causal = SpectralCausality(res, n_frequencies=64).compute() >>> curve = causal.pair("rate", "gdp") >>> curve.shape, bool(np.all(curve >= 0.0)), bool(curve[0] > curve[-1]) ((64,), True, True) >>> bool(np.array_equal(curve, causal.measure[:, 0, 1])) True