hp_filter – Hodrick-Prescott filter – trend / cycle decomposition.#
Back to op axis | Back to L3 | Browse all options
Operational op under axis
op, sub-layerL3_A_step_op, layerl3. Standalone callable:mf.functions.hp_filter_transform.
Function signature#
mf.functions.hp_filter_transform(
panel: pd.DataFrame,
lambda_: float,
) -> pd.DataFrame
Parameters#
name |
type |
default |
constraint |
description |
|---|---|---|---|---|
|
|
— |
— |
Input panel. Each column is a variable; rows are time periods. Series is promoted to a single-column DataFrame internally. |
|
|
|
> 0 |
HP smoothing parameter. Convention: 1600 for quarterly, 129600 for monthly (Ravn-Uhlig 2002). |
Returns#
pd.DataFrame — scalar result.
Behavior#
statsmodels hpfilter with smoothing parameter params.lamb (1600 for quarterly, 129600 for monthly per Ravn-Uhlig 2002). Returns the cyclical component by default; the trend can also be returned via params.return = 'trend'.
When to use
Extracting business-cycle gaps from trending series.
When NOT to use
Real-time / one-sided forecasting – HP introduces look-ahead bias unless restricted to expanding_window_per_origin.
In recipe context#
Set params.op = "hp_filter" in the relevant layer to activate this op within a recipe:
# Layer L3 recipe fragment
params:
op: hp_filter
References#
macroforecast design Part 2, L3: ‘feature engineering is a DAG of typed transforms; cascade-depth bounds the longest chain at cascade_max_depth.’
Hodrick & Prescott (1997) ‘Postwar U.S. Business Cycles: An Empirical Investigation’, JMCB 29(1): 1-16.