SpectralCausality.compute#

SpectralCausality.compute()[source]#

Decompose every ordered pair.

The transfer function is evaluated on the full circle of 2 (n - 1) points so that the factorization has the whole density; the measure is read back on the [0, pi] half. For k = 2 the model’s own transfer function and covariance feed _pairwise_measure directly, once in each direction by swapping the pair’s axes; for k > 2 each pair’s marginal density is cut from the system’s spectral matrix and factored first. Deterministic.

Return type:

SpectralCausalityResult

Returns:

The SpectralCausalityResult.

Raises:

NumericalError – If a pair’s spectral factorization fails, which for a stable fitted model means its density is degenerate.

Example

>>> import numpy as np
>>> from cultivars.multivariate.reduced_form.vector_autoregression import VAR
>>> y = np.random.default_rng(0).standard_normal((200, 2))
>>> causal = SpectralCausality(VAR(y, order=1).fit(), n_frequencies=16).compute()
>>> causal.frequencies.shape, bool(np.all(causal.measure >= 0.0))
((16,), True)
>>> bool(np.all(np.diagonal(causal.measure, axis1=1, axis2=2) == 0.0))
True