Skip to content

Prefix state Medicaid calibration label with state/#778

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

Prefix state Medicaid calibration label with state/#778
MaxGhenis merged 1 commit intoPolicyEngine:mainfrom
MaxGhenis:fix-state-medicaid-label-prefix

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

The state-level Medicaid enrollment calibration column was labeled irs/medicaid_enrollment/{state}, missing the state/ prefix used by every other state target in build_loss_matrix:

  • Line 849 (sibling ACA enrollment): state/irs/aca_enrollment/{state}
  • Line 1138 SNAP: {r.GEO_ID[-4:]}/snap-cost (state targets)
  • Line 1045 AGI by state: state/{GEO_NAME}/{VARIABLE}/{band}
  • Line 874 Medicaid: irs/medicaid_enrollment/{state} ✗ (missing prefix)

In reweight(), is_national = columns.str.startswith("nation/") — a label starting with irs/ is not classified as national but also doesn't follow the state/ naming convention. It still participates in calibration, but downstream tools that filter targets by prefix (dashboards, validation scripts) silently skip these Medicaid columns.

Fix

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

Test plan

  • CI passes.

The state-level Medicaid enrollment calibration column was labeled
`irs/medicaid_enrollment/{state}`, missing the `state/` prefix used
by every other state target in `build_loss_matrix` (e.g. line 849:
`state/irs/aca_enrollment/{state}`, state SNAP, state AGI).

In `reweight()`, `is_national = columns.str.startswith("nation/")`
and the non-national normalisation factor uses `~is_national`, so
today the label technically lands in the state pool, but it also
isn't tagged as a state target. Downstream tools that filter
targets by the `state/` prefix (dashboards, validation scripts)
silently skip these Medicaid columns.

Fix: prefix with `state/` for consistency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
MaxGhenis added a commit to MaxGhenis/policyengine-us-data that referenced this pull request Apr 17, 2026
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 b9761a6 into PolicyEngine:main Apr 17, 2026
8 of 9 checks passed
MaxGhenis added a commit that referenced this pull request Apr 17, 2026
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 #778 (state
Medicaid label prefix) as an analogous but higher-severity bug
(real calibration-weighting impact vs naming-consistency for #778).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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