Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/contract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 +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`

- **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.
Expand Down
34 changes: 19 additions & 15 deletions integration/src/policyengine_macro/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -586,10 +588,10 @@ 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 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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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.95pp by the fourth quarter. The realised lever path is returned in the results.",
"typical_shock": 0.01,
"requires_policy_rule": None,
},
Expand All @@ -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, 1.01% in the fourth quarter). 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 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,
},
Expand All @@ -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,
Expand Down
82 changes: 82 additions & 0 deletions integration/tests/test_frbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,88 @@ 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"]
# 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
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

# 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[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):
import pandas as pd

Expand Down