From 22a4ea19e2906185c33dad45941f1898bd0b3e0c Mon Sep 17 00:00:00 2001 From: vahid-ahmadi Date: Wed, 25 Nov 2026 00:23:53 +0000 Subject: [PATCH 1/2] FRB/US lever units: rfftay_aerr does not stack, ebfi_aerr keeps building, per-lever stacking figures Co-Authored-By: Claude Fable 5.2 --- .github/workflows/contract.yml | 1 + CHANGELOG.md | 7 +++ integration/src/policyengine_macro/core.py | 30 +++++----- integration/tests/test_frbus.py | 67 ++++++++++++++++++++++ 4 files changed, 92 insertions(+), 13 deletions(-) diff --git a/.github/workflows/contract.yml b/.github/workflows/contract.yml index fe7d081da..2129fc0f0 100644 --- a/.github/workflows/contract.yml +++ b/.github/workflows/contract.yml @@ -37,6 +37,7 @@ jobs: tests/test_frbus.py::test_model_and_data_files_resolve_from_installed_package tests/test_frbus.py::test_tracking_invariant_holds_after_init_trac tests/test_frbus.py::test_monetary_tightening_has_the_documented_signs_and_magnitudes + tests/test_frbus.py::test_stacking_text_matches_the_installed_model --runslow -q env: POLICYENGINE_MACRO_REQUIRE_PE: "1" diff --git a/CHANGELOG.md b/CHANGELOG.md index b2d6829aa..5568bd446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ heading here; `tests/test_repo_hygiene.py` asserts that they do. ## [Unreleased] +### FRB/US lever units: which add-factors stack, and by how much + +- **`rfftay_aerr` does not stack.** The non-inertial Taylor rule has no lag of the funds rate, but the lever carried the inertial rule's text ("periods=4 peaks near +3pp"). Held for four quarters at 1.0 the funds rate is +1.00, +0.82, +0.71, +0.55pp above baseline, never above +1pp. The text now says so. +- **`ebfi_aerr` keeps building.** "1% higher BFI after one period" holds in the shocked quarter only: one 0.01 shock gives +1.0% on impact and about +1.8% a year later. +- **Per-lever stacking figures.** The six fiscal and demand levers shared one sentence quoting egfe and trp. Each now quotes its own fourth-quarter figure for 0.01 held four quarters: egfe 2.9%, egse 3.7%, trp 2.3pp (was "~2.4pp"), trci 2.9pp, consumption 4.2%, BFI 5.9%. `poil_aerr` says +$10 is about 15% of the baseline price in 2026Q1 and about 10% in the next three quarters. +- All figures are from local solves at us-frb-model `162cfe6` (October 2026 LONGBASE) and match the table in us-frb-model #28. A slow test checks them against the installed model in the nightly contract job. Tool text only; no result changes. + ### BoE SVAR re-pin to `17f5d82` - **Pin.** BoE SVAR `c827ab86` → `17f5d824` (boe-var-model #34, world CPI seasonal adjustment; #35, November 2026 MPR comparator and 2026Q3 scoring). After a redeploy the hosted `forecast_uk` and `latest_shocks` run this pin. diff --git a/integration/src/policyengine_macro/core.py b/integration/src/policyengine_macro/core.py index c8aa3809c..69f3bd257 100644 --- a/integration/src/policyengine_macro/core.py +++ b/integration/src/policyengine_macro/core.py @@ -574,10 +574,12 @@ def obr_shock( "description": "Add-error on the non-inertial Taylor rule — the " "monetary policy shock when policy_rule='taylor'", "units": "percentage points on the funds rate, PER SHOCKED PERIOD " - "(1.0 = 100bp). With periods>1 the add-factors stack: " - "shock=1.0, periods=4 peaks near +3pp on the funds " - "rate, not +1pp — set periods=1 for a one-quarter " - "100bp move.", + "(1.0 = 100bp). This rule has no lag of the funds rate, so " + "the add-factor does not stack: shock=1.0, periods=4 puts " + "the funds rate +1.00pp above baseline in the first " + "quarter and then lower as the rule responds (+0.82, " + "+0.71, +0.55pp), never above +1pp. The inertial rule's " + "lever (rffintay_aerr) does stack.", "typical_shock": 1.0, "requires_policy_rule": "taylor", }, @@ -589,7 +591,7 @@ def obr_shock( "level of federal purchases; egfe is ~4.6% of GDP, so 0.01 " "is roughly 0.046% of GDP). NOT billions of dollars — a " "shock of order 1 or more diverges the solver." - " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised level move exceeds one period's shock (periods=4 at 0.01 lifts egfe ~2.9%, trp ~+2.4pp); the realised lever path is returned in the results.", + " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 lifts egfe 2.9% by the fourth quarter. The realised lever path is returned in the results.", "typical_shock": 0.01, "requires_policy_rule": None, }, @@ -598,7 +600,7 @@ def obr_shock( "description": "Add-error on state and local government purchases", "units": "log points of quarterly growth in egse (0.01 ~ a 1% higher " "level of S&L purchases after one period)." - " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised level move exceeds one period's shock (periods=4 at 0.01 lifts egfe ~2.9%, trp ~+2.4pp); the realised lever path is returned in the results.", + " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 lifts egse 3.7% by the fourth quarter. The realised lever path is returned in the results.", "typical_shock": 0.01, "requires_policy_rule": None, }, @@ -607,7 +609,7 @@ def obr_shock( "description": "Add-error on the personal income tax rate", "units": "decimal rate change (0.01 = a 1 percentage point rise in the " "effective personal tax rate on impact)." - " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised level move exceeds one period's shock (periods=4 at 0.01 lifts egfe ~2.9%, trp ~+2.4pp); the realised lever path is returned in the results.", + " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 raises trp 2.3pp by the fourth quarter. The realised lever path is returned in the results.", "typical_shock": 0.01, "requires_policy_rule": None, }, @@ -616,7 +618,7 @@ def obr_shock( "description": "Add-error on the corporate income tax rate", "units": "decimal rate change (0.01 = a 1pp rise in the effective " "corporate tax rate on impact)." - " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised level move exceeds one period's shock (periods=4 at 0.01 lifts egfe ~2.9%, trp ~+2.4pp); the realised lever path is returned in the results.", + " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 raises trci 2.9pp by the fourth quarter. The realised lever path is returned in the results.", "typical_shock": 0.01, "requires_policy_rule": None, }, @@ -627,16 +629,17 @@ def obr_shock( "units": "log points of quarterly consumption growth (0.01 ~ 1% higher " "consumption after one period; large, since consumption is " "~68% of GDP)." - " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised level move exceeds one period's shock (periods=4 at 0.01 lifts egfe ~2.9%, trp ~+2.4pp); the realised lever path is returned in the results.", + " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 lifts consumption 4.2% by the fourth quarter, and a one-period shock barely decays (1.06% on impact, 0.97% a year later). The realised lever path is returned in the results.", "typical_shock": 0.01, "requires_policy_rule": None, }, { "var": "ebfi_aerr", "description": "Add-error on business fixed investment", - "units": "log points of quarterly BFI growth (0.01 ~ 1% higher BFI " - "after one period)." - " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised level move exceeds one period's shock (periods=4 at 0.01 lifts egfe ~2.9%, trp ~+2.4pp); the realised lever path is returned in the results.", + "units": "log points of quarterly BFI growth (0.01 ~ 1.0% higher BFI " + "in the shocked quarter only: the response keeps building " + "after a one-period shock, to about 1.8% a year later)." + " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 lifts BFI 5.9% by the fourth quarter. The realised lever path is returned in the results.", "typical_shock": 0.01, "requires_policy_rule": None, }, @@ -645,7 +648,8 @@ def obr_shock( "description": "Add-error on the price of imported oil (an identity, " "poil = poilr*pxb + poil_aerr) — an oil-price shock", "units": "US dollars per barrel added to the oil price LEVEL (+10 is " - "about +15% at the 2026 LONGBASE price). An identity, so it " + "about +15% of the baseline price in 2026Q1 and about +10% " + "in the next three quarters). An identity, so it " "does not stack over periods: periods=4 holds the price " "+$10 for four quarters.", "typical_shock": 10.0, diff --git a/integration/tests/test_frbus.py b/integration/tests/test_frbus.py index a71089118..1cf08d770 100644 --- a/integration/tests/test_frbus.py +++ b/integration/tests/test_frbus.py @@ -341,6 +341,73 @@ def test_every_stacking_lever_says_so_and_poil_has_real_units(): assert "PER SHOCKED PERIOD" in entry["units"], entry["var"] +# Levers whose own equation carries the shock forward, so holding the +# add-error for several quarters builds the move up. Measured at us-frb-model +# 162cfe6 (October 2026 LONGBASE), shock from 2026Q1; the same table is pinned +# upstream in us-frb-model #28. +_FRBUS_STACKING = { + # lever: (own variable, shock, policy rule, own variable in the fourth + # of four shocked quarters: % for levels, decimal for tax rates) + "rffintay_aerr": ("rff", 1.0, None, 2.97), + "egfe_aerr": ("egfe", 0.01, None, 2.90), + "egse_aerr": ("egse", 0.01, None, 3.71), + "trp_aerr": ("trp", 0.01, None, 0.0233), + "trci_aerr": ("trci", 0.01, None, 0.0295), + "ecnia_aerr": ("ecnia", 0.01, None, 4.19), + "ebfi_aerr": ("ebfi", 0.01, None, 5.95), +} +_FRBUS_NOT_STACKING = ("rfftay_aerr", "poil_aerr") + + +def test_stacking_text_matches_which_levers_stack(): + """The non-inertial Taylor rule has no lag of the funds rate, so its + add-factor does not stack; before 25 Nov 2026 it carried the inertial + rule's "peaks near +3pp" text. Every curated lever is in exactly one of + the two lists, and its units string says the right thing.""" + index = core._FRBUS_VAR_INDEX + assert set(_FRBUS_STACKING) | set(_FRBUS_NOT_STACKING) == set(index) + for var in _FRBUS_NOT_STACKING: + assert "does not stack" in index[var]["units"], var + assert "+3pp" not in index[var]["units"], var + for var in _FRBUS_STACKING: + units = index[var]["units"] + assert "does not stack" not in units, var + assert "stack" in units or "accumulate" in units, var + # A one-period investment shock keeps building; the text must not say + # the level is 1% higher "after one period" and stop there. + assert "keeps building" in index["ebfi_aerr"]["units"] + + +@pytest.mark.slow +def test_stacking_text_matches_the_installed_model(): + """The figures the units strings quote, against a real solve.""" + pytest.importorskip("frbus") + + def own_path(var, own, shock, periods, rule=None): + kwargs = {"policy_rule": rule} if rule else {} + res = core.frbus_shock(var, shock, periods=periods, horizon=8, **kwargs) + return [row[own] for row in res["results"]] + + for var, (own, shock, rule, q4) in _FRBUS_STACKING.items(): + path = own_path(var, own, shock, 4, rule) + assert path[3] == pytest.approx(q4, rel=0.02), (var, path) + assert abs(path[3]) > 2 * abs(path[0]), (var, path) + + taylor = own_path("rfftay_aerr", "rff", 1.0, 4, "taylor") + assert taylor[0] == pytest.approx(1.0, abs=0.01) + assert max(taylor) < 1.01, taylor + assert taylor[1:4] == pytest.approx([0.82, 0.71, 0.55], abs=0.01) + + oil = own_path("poil_aerr", "poil", 10.0, 4) + # Reported as a % of the baseline price, which differs by quarter; held + # in dollars, it never builds up. + assert max(oil[:4]) == oil[0] and min(oil[:4]) > 0.6 * oil[0], oil + + bfi = own_path("ebfi_aerr", "ebfi", 0.01, 1) + assert bfi[0] == pytest.approx(1.0, abs=0.02) + assert bfi[4] == pytest.approx(1.85, abs=0.05) and bfi[4] > bfi[0] + + def _fake_frbus(monkeypatch): import pandas as pd From 2babc0e695a2448c13c9a258f9b6662a63c561f7 Mon Sep 17 00:00:00 2001 From: vahid-ahmadi Date: Wed, 25 Nov 2026 02:17:47 +0000 Subject: [PATCH 2/2] FRB/US lever text: align with us-frb-model #28's table (egfe share, q4 figures, two decimals) - egfe is ~4.5% of real GDP, so 0.01 is ~0.045% of GDP (was 4.6%, 0.046%). - One-quarter responses are quoted in q4, the fourth quarter, as #28's table does: ecnia 1.01% (was 0.97%, the fifth quarter) and ebfi 1.79% (was 'about 1.8% a year later'). The slow test pins index 3, not index 4. - trci 2.95pp and BFI 5.95% to two decimals, as #28 prints them. Checked against VALIDATION.md at us-frb-model 0185ca0 and a local solve. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 ++-- integration/src/policyengine_macro/core.py | 12 ++++++------ integration/tests/test_frbus.py | 17 ++++++++++++++++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5568bd446..01258acab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,8 @@ heading here; `tests/test_repo_hygiene.py` asserts that they do. ### FRB/US lever units: which add-factors stack, and by how much - **`rfftay_aerr` does not stack.** The non-inertial Taylor rule has no lag of the funds rate, but the lever carried the inertial rule's text ("periods=4 peaks near +3pp"). Held for four quarters at 1.0 the funds rate is +1.00, +0.82, +0.71, +0.55pp above baseline, never above +1pp. The text now says so. -- **`ebfi_aerr` keeps building.** "1% higher BFI after one period" holds in the shocked quarter only: one 0.01 shock gives +1.0% on impact and about +1.8% a year later. -- **Per-lever stacking figures.** The six fiscal and demand levers shared one sentence quoting egfe and trp. Each now quotes its own fourth-quarter figure for 0.01 held four quarters: egfe 2.9%, egse 3.7%, trp 2.3pp (was "~2.4pp"), trci 2.9pp, consumption 4.2%, BFI 5.9%. `poil_aerr` says +$10 is about 15% of the baseline price in 2026Q1 and about 10% in the next three quarters. +- **`ebfi_aerr` keeps building.** "1% higher BFI after one period" holds in the shocked quarter only: one 0.01 shock gives +1.0% on impact and +1.79% in the fourth quarter (q4, three quarters after the shock). +- **Per-lever stacking figures.** The six fiscal and demand levers shared one sentence quoting egfe and trp. Each now quotes its own fourth-quarter figure for 0.01 held four quarters: egfe 2.9%, egse 3.7%, trp 2.3pp (was "~2.4pp"), trci 2.95pp, consumption 4.2%, BFI 5.95%. A one-quarter consumption shock is 1.06% on impact and 1.01% in q4. `egfe_aerr` says egfe is about 4.5% of real GDP, so 0.01 is about 0.045% of GDP (was 4.6% and 0.046%). `poil_aerr` says +$10 is about 15% of the baseline price in 2026Q1 and about 10% in the next three quarters. - All figures are from local solves at us-frb-model `162cfe6` (October 2026 LONGBASE) and match the table in us-frb-model #28. A slow test checks them against the installed model in the nightly contract job. Tool text only; no result changes. ### BoE SVAR re-pin to `17f5d82` diff --git a/integration/src/policyengine_macro/core.py b/integration/src/policyengine_macro/core.py index 69f3bd257..5fd6ee177 100644 --- a/integration/src/policyengine_macro/core.py +++ b/integration/src/policyengine_macro/core.py @@ -588,8 +588,8 @@ def obr_shock( "description": "Add-error on federal government purchases (defence + " "non-defence consumption and investment)", "units": "LOG POINTS of quarterly growth in egfe (0.01 ~ a 1% higher " - "level of federal purchases; egfe is ~4.6% of GDP, so 0.01 " - "is roughly 0.046% of GDP). NOT billions of dollars — a " + "level of federal purchases; egfe is ~4.5% of real GDP, so 0.01 " + "is roughly 0.045% of GDP). NOT billions of dollars — a " "shock of order 1 or more diverges the solver." " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 lifts egfe 2.9% by the fourth quarter. The realised lever path is returned in the results.", "typical_shock": 0.01, @@ -618,7 +618,7 @@ def obr_shock( "description": "Add-error on the corporate income tax rate", "units": "decimal rate change (0.01 = a 1pp rise in the effective " "corporate tax rate on impact)." - " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 raises trci 2.9pp by the fourth quarter. The realised lever path is returned in the results.", + " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 raises trci 2.95pp by the fourth quarter. The realised lever path is returned in the results.", "typical_shock": 0.01, "requires_policy_rule": None, }, @@ -629,7 +629,7 @@ def obr_shock( "units": "log points of quarterly consumption growth (0.01 ~ 1% higher " "consumption after one period; large, since consumption is " "~68% of GDP)." - " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 lifts consumption 4.2% by the fourth quarter, and a one-period shock barely decays (1.06% on impact, 0.97% a year later). The realised lever path is returned in the results.", + " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 lifts consumption 4.2% by the fourth quarter, and a one-period shock barely decays (1.06% on impact, 1.01% in the fourth quarter). The realised lever path is returned in the results.", "typical_shock": 0.01, "requires_policy_rule": None, }, @@ -638,8 +638,8 @@ def obr_shock( "description": "Add-error on business fixed investment", "units": "log points of quarterly BFI growth (0.01 ~ 1.0% higher BFI " "in the shocked quarter only: the response keeps building " - "after a one-period shock, to about 1.8% a year later)." - " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 lifts BFI 5.9% by the fourth quarter. The realised lever path is returned in the results.", + "after a one-period shock, to 1.79% in the fourth quarter)." + " PER SHOCKED PERIOD: with periods>1 the add-errors accumulate through the equation's own lags, so the realised move exceeds one period's shock: 0.01 held for periods=4 lifts BFI 5.95% by the fourth quarter. The realised lever path is returned in the results.", "typical_shock": 0.01, "requires_policy_rule": None, }, diff --git a/integration/tests/test_frbus.py b/integration/tests/test_frbus.py index 1cf08d770..aa32bc4b1 100644 --- a/integration/tests/test_frbus.py +++ b/integration/tests/test_frbus.py @@ -376,6 +376,15 @@ def test_stacking_text_matches_which_levers_stack(): # A one-period investment shock keeps building; the text must not say # the level is 1% higher "after one period" and stop there. assert "keeps building" in index["ebfi_aerr"]["units"] + # The figures us-frb-model #28's VALIDATION.md table prints, to its + # decimals: egfe is 4.5% of real GDP in 2026Q1, and the one-quarter + # responses are quoted in q4 (the fourth quarter), as that table does. + assert "~4.5% of real GDP" in index["egfe_aerr"]["units"] + assert "0.045% of GDP" in index["egfe_aerr"]["units"] + assert "trci 2.95pp" in index["trci_aerr"]["units"] + assert "BFI 5.95%" in index["ebfi_aerr"]["units"] + assert "1.79% in the fourth quarter" in index["ebfi_aerr"]["units"] + assert "1.01% in the fourth quarter" in index["ecnia_aerr"]["units"] @pytest.mark.slow @@ -403,9 +412,15 @@ def own_path(var, own, shock, periods, rule=None): # in dollars, it never builds up. assert max(oil[:4]) == oil[0] and min(oil[:4]) > 0.6 * oil[0], oil + # One shocked quarter: index 0 is the shocked quarter (q1) and index 3 + # is q4, the column us-frb-model #28's table reports. bfi = own_path("ebfi_aerr", "ebfi", 0.01, 1) assert bfi[0] == pytest.approx(1.0, abs=0.02) - assert bfi[4] == pytest.approx(1.85, abs=0.05) and bfi[4] > bfi[0] + assert bfi[3] == pytest.approx(1.79, abs=0.02) and bfi[4] > bfi[3] + + cons = own_path("ecnia_aerr", "ecnia", 0.01, 1) + assert cons[0] == pytest.approx(1.06, abs=0.01) + assert cons[3] == pytest.approx(1.01, abs=0.01) def _fake_frbus(monkeypatch):