apply_official_tcode – Apply McCracken-Ng’s series-by-series stationarity transforms.#
Back to transform_policy axis | Back to L2 | Browse all options
Operational op under axis
transform_policy, sub-layerl2_b, layerl2. Standalone callable:mf.functions.apply_tcode_transform.
Function signature#
mf.functions.apply_tcode_transform(
panel: pd.DataFrame,
tcode_map: dict[str, 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. |
|
|
— |
— |
Mapping from column name to McCracken-Ng t-code integer 1..7. Columns not in tcode_map are passed through unchanged. |
Returns#
pd.DataFrame — scalar result.
Behavior#
Each FRED-MD/QD series ships with a transformation code (1-7) mapping to a stationarity transform. apply_official_tcode runs the canonical mapping per series:
1 = level
2 = first difference
3 = second difference
4 = log
5 = first difference of log (≈ growth rate)
6 = second difference of log
7 = log diff of (1 + growth rate)
Applied per-origin within walk-forward to avoid look-ahead.
When to use
Default for FRED-based studies. Canonical replication path.
In recipe context#
Set params.transform_policy = "apply_official_tcode" in the relevant layer to activate this op within a recipe:
# Layer L2 recipe fragment
params:
transform_policy: apply_official_tcode
References#
macroforecast design Part 2, L2: ‘preprocessing is the only layer with a strict A→B→C→D→E execution order; every cell follows the same pipeline.’
McCracken & Ng (2016) ‘FRED-MD: A Monthly Database for Macroeconomic Research’, JBES 34(4). (doi:10.1080/07350015.2015.1086655)