SpectralCausalityResult.band#

SpectralCausalityResult.band(cause, effect, *, low_period, high_period)[source]#

One pair’s measure averaged over a period band.

The mean of \(f_{j \to i}\) over the grid frequencies inside \([2\pi / \texttt{high\_period},\ 2\pi / \texttt{low\_period}]\), the business-cycle slice of the curve when the band is the Burns-Mitchell one.

Parameters:
  • cause (str) – The variable whose history is being credited.

  • effect (str) – The variable whose spectrum is being decomposed.

  • low_period (float) – Shortest period in the band, in observations per cycle (6 for the quarterly business-cycle convention).

  • high_period (float) – Longest period in the band (32 quarterly).

Return type:

float

Returns:

The average measure over frequencies [2 pi / high_period, 2 pi / low_period].

Raises:

SpecificationError – If the band is malformed or misses the grid.

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()
>>> causal = SpectralCausality(res, n_frequencies=64).compute()
>>> cycle = causal.band("rate", "gdp", low_period=6, high_period=32)
>>> short = causal.band("rate", "gdp", low_period=2, high_period=4)
>>> bool(cycle > short)
True
>>> causal.band("rate", "gdp", low_period=32, high_period=6)
Traceback (most recent call last):
    ...
cultivars.exceptions.SpecificationError: periods must satisfy 0 < low_period < ...