SpectralCausalityResult#
- class cultivars.spectral.causality.SpectralCausalityResult(*, names, frequencies, measure)[source]#
All ordered pairs’ unconditional Geweke measures across frequency.
For each ordered pair the effect’s spectrum at frequency \(\omega\) is split, in the pair’s own innovation representation \((H, \Sigma)\) with the instantaneous correlation rotated out of the cause’s innovation, into an intrinsic part and a part driven by the cause’s innovations, and the measure is the log ratio of total to intrinsic,
\[f_{j \to i}(\omega) = \ln \frac{S_{ii}(\omega)} {H_{ii}(\omega)\, \tilde\Sigma_{ii}\, \overline{H_{ii}(\omega)}} \;\ge\; 0,\]with \(S_{ii} = [H \Sigma H^\ast]_{ii}\) the effect’s spectrum and \(\tilde\Sigma_{ii}\) its innovation variance after the rotation. Zero at a frequency says the cause’s history contributes nothing to the effect’s variance at that cycle length; the integral over \([0, \pi]\) divided by \(\pi\) recovers Geweke’s time-domain measure \(\ln(\sigma^2_{\text{restricted}} / \sigma^2_{\text{full}})\), so the curve is the Granger statement resolved by frequency.
- Variables:
names – Variable labels, indexing the measure’s matrix axes.
frequencies – The
(n,)grid on[0, pi].measure – The
(n, k, k)measure; entry[w, i, j]is the causality from variablejto variableiat frequencyw. The diagonal is zero by convention.
Note
The axis order is
[effect, cause], the convention of the Geweke literature and ofintegrated(), someasure[:, i, j]reads “jcausesi”;pair()takes the arguments in the spoken order(cause, effect)and does the transposition. The measures are unconditional: a third variable driving both members of a pair shows up as causality between them, which is whatConditionalSpectralCausalityResultremoves.See also
SpectralCausality– the producer.ConditionalSpectralCausalityResult– the same measure with the rest of the system conditioned out.SpectralDensityResult– the spectral matrix and coherence the measure decomposes.
References
Geweke, J. (1982). Measurement of linear dependence and feedback between multiple time series. Journal of the American Statistical Association, 77(378), 304-313.
Ding, M., Chen, Y., & Bressler, S. L. (2006). Granger causality: Basic theory and application to neuroscience. In Handbook of Time Series Analysis (pp. 437-460). Wiley.
Example
A rate that feeds into output with no feedback; the integrated spectral measure matches the time-domain Granger measure from the restricted and full regressions:
>>> 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() >>> causal.measure.shape, causal.k_endog ((64, 2, 2), 2) >>> causal.integrated().round(3) array([[0. , 0.154], [0.001, 0. ]]) >>> round(causal.band("rate", "gdp", low_period=6, high_period=32), 3) 0.261 >>> own = np.column_stack([np.ones(499), y[:-1, 0]]) >>> both = np.column_stack([own, y[:-1, 1]]) >>> fit = lambda x: y[1:, 0] - x @ np.linalg.lstsq(x, y[1:, 0], rcond=None)[0] >>> round(float(np.log(fit(own).var() / fit(both).var())), 3) 0.153
Attributes#
Variable labels, indexing both matrix axes of |
|
|
|
|
|
Number of variables, \(k\), the size of each matrix axis. |
Methods#
|
One pair's measure averaged over a period band. |
The measures integrated over frequency: the time-domain reading. |
|
|
One directed pair's measure across the grid. |
|
The estimation summary, renderable as text, HTML, or a dataframe. |