From 11342748e1d02e4446222a180afcf47b2ee67e2f Mon Sep 17 00:00:00 2001 From: vahid-ahmadi Date: Wed, 25 Nov 2026 00:08:44 +0000 Subject: [PATCH] hank_shock_incidence: state the labour-tax financing the overlay does not apply (#214) The overlay scales pre-tax employment income by the HANK w and N paths. The model also moves the labour tax rate every period to balance the government budget; nothing in the result said so. Add a caveat with the model's annual-mean tax change and report it in the application block. No incidence number changes. Co-Authored-By: Claude Fable 5.2 --- CHANGELOG.md | 5 ++ .../src/policyengine_macro/assumptions.py | 27 +++++++++ integration/src/policyengine_macro/core.py | 19 ++++++ .../src/policyengine_macro/mcp_server.py | 7 ++- integration/tests/test_incidence.py | 59 +++++++++++++++++++ 5 files changed, 116 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2d6829aa..4b29cd19b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ heading here; `tests/test_repo_hygiene.py` asserts that they do. ## [Unreleased] +### `hank_shock_incidence`: state the labour-tax financing the overlay leaves out (#214) + +- **Gap.** The overlay scales pre-tax employment income by the HANK wage and labor paths and leaves PolicyEngine's taxes unchanged. In the model the labour tax rate moves every period to balance the government budget, and nothing in the result said that leg was missing. At us-hank-model `58353e5`, a spending rise of 1% of GDP (persistence 0.8) gives a pre-tax earnings factor of +0.28% for the first year while the model's labour tax rate is 1.16pp higher on average. +- **Change.** The result now carries a caveat saying the financing is not applied, with the model's annual-mean tax change, and reports it as `application.labour_tax_rate_change_pp_not_applied`. The applied earnings factor and every incidence number are unchanged; applying the tax leg is a separate decision. + ### 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/assumptions.py b/integration/src/policyengine_macro/assumptions.py index 0bf4a9251..3afff85e5 100644 --- a/integration/src/policyengine_macro/assumptions.py +++ b/integration/src/policyengine_macro/assumptions.py @@ -413,7 +413,34 @@ def _annual_mean(series: str) -> float: "against a 0.0 baseline convention" ) notes.append(rate_note) + # The financing leg the overlay leaves out (macro #214). The DAG + # holds bond supply fixed and balances the government budget every + # period with the labour tax rate, so the model's households see a + # tax change alongside the pre-tax wage and labor paths. The overlay + # applies only the pre-tax paths; say so, and report the size. + financing_caveat = ( + "HANK's labour-tax financing is not applied: in the model the " + "labour tax rate moves every period to balance the government " + "budget, so households' post-tax labour income changes by a " + "different amount from the pre-tax earnings factor used here" + ) + if "tax" in rows[0]: + tax_pp = _annual_mean("tax") + notes.append( + f"labour tax rate: the model moves it {tax_pp:+.3f}pp on " + f"average over {year} to balance the government budget; " + "reported, not applied (PolicyEngine's statutory taxes are " + "the same on both sides)" + ) + financing_caveat += ( + f" (the model's rate is {tax_pp:+.3f}pp from steady state " + f"on average over {year}). Where the tax rate and pre-tax " + "earnings move in the same direction they work against " + "each other, and the net effect on workers' income can " + "have the opposite sign from the one reported" + ) caveats = [ + financing_caveat, "uniform scaling understates distributional incidence: actual " "labour-market adjustment concentrates in job losers, while " "the overlay spreads the change evenly over all employment " diff --git a/integration/src/policyengine_macro/core.py b/integration/src/policyengine_macro/core.py index c8aa3809c..8ddd07118 100644 --- a/integration/src/policyengine_macro/core.py +++ b/integration/src/policyengine_macro/core.py @@ -4125,6 +4125,19 @@ def frbus_shock_incidence( return out +def _hank_tax_annual_mean(payload: dict, year: int, start_year: int): + """Annual mean of the HANK labour tax path (pp) over ``year``, or None. + + The same four quarters from_hank_result averages for w and N. None when + the payload carries no ``tax`` series, never a zero. + """ + offset = 4 * (int(year) - int(start_year)) + window = payload["results"][offset:offset + 4] + if len(window) < 4 or any("tax" not in r for r in window): + return None + return round(sum(float(r["tax"]) for r in window) / 4.0, 6) + + def hank_shock_incidence( kind: str, size: float, @@ -4216,6 +4229,12 @@ def hank_shock_incidence( "variables_tried": list(SCALED_INPUT_VARIABLES), "earnings_factor": ea.earnings_factor, "applied": modifier is not None, + # The model's financing of the shock, which the overlay does not + # apply (#214): annual mean of the labour tax rate's pp deviation + # over the incidence year. None when the payload has no tax path. + "labour_tax_rate_change_pp_not_applied": _hank_tax_annual_mean( + payload, year, start_year + ), }, "microsim": micro, "assumptions": assumptions, diff --git a/integration/src/policyengine_macro/mcp_server.py b/integration/src/policyengine_macro/mcp_server.py index 4c275a9f7..34be4beb3 100644 --- a/integration/src/policyengine_macro/mcp_server.py +++ b/integration/src/policyengine_macro/mcp_server.py @@ -579,7 +579,12 @@ def hank_shock_incidence( stylized model around the Auclert-Bardóczy-Rognlie-Straub 2021 calibrated steady state, not a US forecast baseline); allocate job losses to individual households (uniform scaling — stated in - caveats). US only. + caveats); apply the model's financing. In HANK the labour tax rate + moves every period to balance the government budget (it rises after a + spending increase), and the overlay leaves that out: it scales pre-tax + earnings only. The model's tax change is reported as + application.labour_tax_rate_change_pp_not_applied and in the caveats, + and for a spending shock it can outweigh the pre-tax gain. US only. Returns the hank payload, the economic_assumptions factors, an `application` block, the microsim incidence block, and a common diff --git a/integration/tests/test_incidence.py b/integration/tests/test_incidence.py index 5640b548d..ed3f4f93c 100644 --- a/integration/tests/test_incidence.py +++ b/integration/tests/test_incidence.py @@ -423,6 +423,65 @@ def fake_incidence(country, year, dataset, modifier, label): json.dumps(res) +def _hank_with_tax(tax_by_quarter): + payload = _synthetic_hank(w=0.2, n=0.11, quarters=len(tax_by_quarter)) + for row, tax in zip(payload["results"], tax_by_quarter): + row["tax"] = tax + return payload + + +def test_from_hank_states_the_unapplied_labour_tax_financing(): + """The overlay scales pre-tax earnings; the model also moves the labour + tax rate to balance the budget (macro #214). For a spending rise that tax + rise can outweigh the pre-tax gain, so the caveat and the size must be in + the payload, not left to the model's README.""" + ea = EconomicAssumptions.from_hank_result( + _hank_with_tax([0.5, 1.5, 1.0, 1.0]), year=2026 + ) + financing = [c for c in ea.caveat_strings() if "labour-tax financing" in c] + assert len(financing) == 1 + assert "not applied" in financing[0] + assert "+1.000pp" in financing[0] + assert any("+1.000pp" in n and "not applied" in n for n in ea.notes) + # Reported only: the applied factor is still the pre-tax wage bill. + assert ea.earnings_factor == pytest.approx(1.0031) + + +def test_from_hank_financing_caveat_without_a_tax_series(): + """An older payload has no tax path: keep the caveat, invent no number.""" + ea = EconomicAssumptions.from_hank_result(_synthetic_hank(), year=2026) + financing = [c for c in ea.caveat_strings() if "labour-tax financing" in c] + assert len(financing) == 1 + assert "pp from steady state" not in financing[0] + assert not any("labour tax rate" in n for n in ea.notes) + + +def test_hank_shock_incidence_reports_the_tax_path_it_does_not_apply( + monkeypatch, +): + payload = _hank_with_tax([0.0, 0.0, 0.0, 0.0, -0.4, -0.2, -0.2, -0.4]) + monkeypatch.setattr(core, "hank_shock", lambda **kw: payload) + monkeypatch.setattr( + core, "_pe_population_incidence", + lambda country, year, dataset, modifier, label: dict(_FAKE_MICRO), + ) + res = core.hank_shock_incidence( + kind="monetary", size=-0.0025, year=2027, start_year=2026, + ) + app = res["application"] + assert app["labour_tax_rate_change_pp_not_applied"] == pytest.approx(-0.3) + for caveats in (res["caveats"], res["score"]["caveats"]): + assert any("labour-tax financing" in c for c in caveats) + + for row in payload["results"]: + del row["tax"] + res = core.hank_shock_incidence( + kind="monetary", size=-0.0025, year=2027, start_year=2026, + ) + assert res["application"]["labour_tax_rate_change_pp_not_applied"] is None + json.dumps(res, allow_nan=False) + + # --------------------------------------------------------------------------- # svar_inflation_incidence with a stubbed forecast, parameter tree, microsim # ---------------------------------------------------------------------------