SpectralDensityResult.spectrum#

SpectralDensityResult.spectrum(name)[source]#

One variable’s power spectrum.

The diagonal of the density matrix, \(f_{ii}(\omega)\): where in frequency this variable’s variance lives. Twice its integral over \([0, \pi]\) is the model’s unconditional variance of the variable.

Parameters:

name (str) – An endogenous variable.

Return type:

NDArray[double]

Returns:

A real (n,) array.

Raises:

SpecificationError – If the 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.7 * y[t - 1] + rng.standard_normal(2)
>>> density = SpectralDensity(VAR(y, order=1).fit(), n_frequencies=64).compute()
>>> power = density.spectrum("y1")
>>> power.shape, bool(power[0] > power[-1])
((64,), True)