Skip to content

Prefix state ACA spending calibration label with state/#779

Merged
MaxGhenis merged 1 commit intoPolicyEngine:mainfrom
MaxGhenis:fix-state-aca-spending-label-prefix
Apr 17, 2026
Merged

Prefix state ACA spending calibration label with state/#779
MaxGhenis merged 1 commit intoPolicyEngine:mainfrom
MaxGhenis:fix-state-aca-spending-label-prefix

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

_add_aca_and_medicaid_metric_columns at utils/loss.py:820 labels the per-state ACA spending target nation/irs/aca_spending/{state} — starting with nation/ even though every row is specific to one state.

reweight() at datasets/cps/enhanced_cps.py:115 classifies targets via columns.str.startswith("nation/") and normalises nation vs state rows by their relative counts:

is_national = loss_matrix.columns.str.startswith("nation/")
nation_normalisation_factor = is_national * (1 / is_national.sum())
state_normalisation_factor = ~is_national * (1 / (~is_national).sum())

So the ~50 per-state ACA-spending rows were being pooled with true national targets, diluting the national-normalisation weight for real national targets.

Fix

-        label = f"nation/irs/aca_spending/{row['state'].lower()}"
+        label = f"state/irs/aca_spending/{row['state'].lower()}"

Matches the sibling state labels (state/irs/aca_enrollment/{state} at line 849, state/{GEO_NAME}/{VARIABLE}/{band} for AGI, {GEO_ID}/snap-cost for SNAP).

Context

Found during independent review of #778 (state Medicaid label prefix). While #778 was a naming-consistency fix that didn't actually change reweight() behavior (label started with irs/, correctly classified as state), this one genuinely affects calibration weighting because the label starts with nation/.

Test plan

  • CI passes.

Line 820 labeled the per-state ACA spending target
`nation/irs/aca_spending/{state}` — starting with `nation/` even
though every row is specific to one state. `reweight()` classifies
targets via `columns.str.startswith("nation/")` and divides the
normalisation weight by the count of national versus state
targets, so this label was counted as a national target, diluting
the national-target pool with what are actually 50 state rows.

Sibling state labels use `state/` prefixes (e.g. line 849
`state/irs/aca_enrollment/{state}`, state AGI, state SNAP). Fix
the ACA spending label to match.

This was flagged during independent review of PR PolicyEngine#778 (state
Medicaid label prefix) as an analogous but higher-severity bug
(real calibration-weighting impact vs naming-consistency for PolicyEngine#778).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MaxGhenis MaxGhenis merged commit bc8b3e3 into PolicyEngine:main Apr 17, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant