SpectralDensityResult.partial_coherence#
- SpectralDensityResult.partial_coherence(first, second)[source]#
Squared partial coherence, conditioning on all other variables.
Read off the inverse density matrix \(g = f^{-1}\) as
\[\tilde C_{ij}(\omega) = \frac{|g_{ij}(\omega)|^2}{g_{ii}(\omega)\, g_{jj}(\omega)},\]the shared power between the two variables at each frequency once every other variable’s contribution is removed – the frequency-domain partial correlation, squared. For a bivariate system there is nothing to condition on and it equals
coherence().- Parameters:
- Return type:
- Returns:
A real
(n,)array in[0, 1].- 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) >>> z = np.zeros((800, 3)) >>> for t in range(1, 800): ... z[t, 2] = 0.6 * z[t - 1, 2] + rng.standard_normal() ... z[t, 0] = 0.3 * z[t - 1, 0] + 0.8 * z[t - 1, 2] + rng.standard_normal() ... z[t, 1] = 0.3 * z[t - 1, 1] + 0.8 * z[t - 1, 2] + rng.standard_normal() >>> density = SpectralDensity(VAR(z, order=1).fit(), n_frequencies=64).compute() >>> plain = density.coherence("y1", "y2")[1] >>> given = density.partial_coherence("y1", "y2")[1] >>> bool(plain > 0.3), bool(given < 0.1) (True, True)