SpectralDensityResult.phase#
- SpectralDensityResult.phase(effect, cause)[source]#
The phase of the cross-spectrum
f[effect, cause], in radians.\(\arg f_{ij}(\omega)\) with \(i\) the effect and \(j\) the cause. Under the transfer convention \(e^{-i\omega l}\) used throughout the package, a negative phase at frequency \(\omega\) means
causeleadseffectby \(-\phi(\omega) / \omega\) observations at that frequency: foreffect_t = cause_{t-1}exactly, the phase is \(-\omega\) on the whole grid. Half the literature states the mirror convention, so check signs against a known lead before trusting a plot.- Parameters:
- Return type:
- Returns:
A real
(n,)array in(-pi, pi].- Raises:
SpecificationError – If either label is unknown.
Example
A one-period lead recovers the phase \(-\omega\) exactly:
>>> import numpy as np >>> from cultivars.multivariate.reduced_form.vector_autoregression import VAR >>> rng = np.random.default_rng(1) >>> x = rng.standard_normal(2000) >>> y = np.zeros((2000, 2)) >>> y[:, 1] = x >>> y[1:, 0] = x[:-1] + 0.05 * rng.standard_normal(1999) >>> res = VAR(y, order=1, names=("gdp", "rate")).fit() >>> density = SpectralDensity(res, n_frequencies=16).compute() >>> lead = density.phase("gdp", "rate")[1:] / density.frequencies[1:] >>> bool(np.allclose(lead, -1.0, atol=0.01)) True