Transformer
HPFilter
Filter a times series using the Hodrick-Prescott filter.
This is a wrapper around the hpfilter function from statsmodels. (see statsmodels.tsa.filters.hp_filter.hpfilter).
Quickstart
python
from sktime.transformations.hpfilter import HPFilter
estimator = HPFilter(lamb=1600)Tags
Capabilities
- Unequal-length series
- Multivariate: Not supported
- Inverse transform: Not supported
- Missing values: Not supported
- Removes missing values: Not supported
- Equalizes series length: Not supported
Properties
- Input typescitype:transform-input
- Series
- Output typescitype:transform-output
- Series
- Label typescitype:transform-labels
- None
- Fit is emptyfit_is_empty
- Yes
- Keeps the time indextransform-returns-same-time-index
- No
- Requires Xrequires_X
- Yes
- Requires yrequires_y
- No
- X and y need the same indexX-y-must-have-same-index
- No
Parameters(1)
- lambfloat
- The Hodrick-Prescott smoothing parameter. A value of 1600 is suggested for quarterly data. Ravn and Uhlig suggest using a value of 6.25 (1600/4**4) for annual data and 129600 (1600*3**4) for monthly data.
Examples
>>> from sktime.transformations.hpfilter import HPFilter
>>> import pandas as pd
>>> import statsmodels.api as sm
>>> dta = sm. datasets. macrodata. load_pandas (). data
>>> index = pd. period_range ('1959Q1', '2009Q3', freq = 'Q')
>>> dta. set_index (index, inplace = True)
>>> hp = HPFilter (1600)
>>> cycles = hp. fit_transform (X = dta [['realinv' ]])