SpectralDensityResult.gain#
- SpectralDensityResult.gain(effect, cause)[source]#
The gain of the regression of
effectoncauseby frequency.\[G_{ij}(\omega) = \frac{|f_{ij}(\omega)|}{f_{jj}(\omega)},\]with \(i\) the effect and \(j\) the cause: the amplitude multiplier the best linear frequency-wise predictor of
effectfromcauseapplies at each frequency.- Parameters:
- Return type:
- Returns:
A real non-negative
(n,)array.- 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() >>> density = SpectralDensity(res, n_frequencies=64).compute() >>> gain = density.gain("gdp", "rate") >>> gain.shape, bool(np.all(gain >= 0.0)), bool(gain[1] > gain[-1]) ((64,), True, True)