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 + 1weights in"valid"mode, so the result hasnobs - 2Krows aligned with input observationsK .. nobs - K - 1.- Parameters:
data (
ArrayLike) – A(nobs, k)panel or one-dimensional series.- Return type:
- Returns:
The
BandPassResult,2 * truncationrows shorter than the input.- Raises:
DimensionError – If the panel is not one- or two-dimensional.
SpecificationError – If the sample is too short for the truncation.
NumericalError – If the panel is not finite.
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 ...