seasonal_lag – Lag at a seasonal period (e.g. y_{t-12} for monthly data).#
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.seasonal_lag_matrix.
Function signature#
mf.functions.seasonal_lag_matrix(
panel: pd.DataFrame,
seasonal_period: int,
n_seasonal_lags: int,
) -> 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. |
|
|
|
>= 2 |
Seasonal cycle length (12 for monthly, 4 for quarterly). |
|
|
|
>= 1 |
Number of seasonal lags. Shifts by seasonal_period * i. |
Returns#
pd.DataFrame — scalar result.
Behavior#
Standard lag op restricted to the seasonal index (params.lag = 12 for monthly, 4 for quarterly). Useful for year-over-year features and seasonal AR terms.
When to use
Capturing year-over-year persistence; seasonal AR baselines.
When NOT to use
When season_dummy or X-13 deseasonalisation is preferred over lag-based seasonality.
In recipe context#
Set params.op = "seasonal_lag" in the relevant layer to activate this op within a recipe:
# Layer L3 recipe fragment
params:
op: seasonal_lag
References#
macroforecast design Part 2, L3: ‘feature engineering is a DAG of typed transforms; cascade-depth bounds the longest chain at cascade_max_depth.’