BaxterKingFilter.filter#

BaxterKingFilter.filter(data)[source]#

Filter a panel.

The truncated ideal weights are recentred to sum to zero – the Baxter-King adjustment that restores exact removal of the zero frequency, so a constant or linear trend cannot leak into the cycle. Each column is convolved with the 2K + 1 weights in "valid" mode, so the result has nobs - 2K rows aligned with input observations K .. nobs - K - 1.

Parameters:

data (ArrayLike) – A (nobs, k) panel or one-dimensional series.

Return type:

BandPassResult

Returns:

The BandPassResult, 2 * truncation rows shorter than the input.

Raises:

Example

>>> import numpy as np
>>> t = np.arange(300.0)
>>> panel = np.column_stack([np.sin(2 * np.pi * t / 12), np.cos(2 * np.pi * t / 20)])
>>> res = BaxterKingFilter().filter(panel)
>>> res.cycle.shape, res.n_series, res.offset
((276, 2), 2, 12)
>>> BaxterKingFilter(truncation=12).filter(np.zeros(24))
Traceback (most recent call last):
    ...
cultivars.exceptions.SpecificationError: a sample of 24 rows is too short for ...