Skip to content

Commit a4e3d4d

Browse files
MaxGhenisclaude
andauthored
Use time_period for ACA and Medicaid metric columns (#777)
`build_loss_matrix` threads a `time_period` argument through its SOI, CBO, and demographic target loops, but several ACA and Medicaid metric-column calls hardcoded `period=2025`: - National ACA spending and enrollment (lines 564, 570) - State ACA PTC spending-by-state (line 817) - State ACA enrollment flags (lines 835, 838) - State Medicaid enrollment and eligibility (lines 863, 865) Any calibration run for a year != 2025 therefore mixed 2025-priced PTC / 2025 enrollment flags with the requested time_period's spending/enrollment targets. Pass `time_period` to every PTC/medicaid calculation so each metric column reflects the target year. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d1f59c3 commit a4e3d4d

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace hardcoded period=2025 in ACA/Medicaid calibration metric columns with the build_loss_matrix time_period argument.

policyengine_us_data/utils/loss.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,15 @@ def build_loss_matrix(dataset: type, time_period):
561561

562562
label = "nation/gov/aca_spending"
563563
loss_matrix[label] = sim.calculate(
564-
"aca_ptc", map_to="household", period=2025
564+
"aca_ptc", map_to="household", period=time_period
565565
).values
566566
targets_array.append(aca_spending_target)
567567

568568
# National ACA Enrollment (people receiving a PTC)
569569
label = "nation/gov/aca_enrollment"
570-
on_ptc = (sim.calculate("aca_ptc", map_to="person", period=2025).values > 0).astype(
571-
int
572-
)
570+
on_ptc = (
571+
sim.calculate("aca_ptc", map_to="person", period=time_period).values > 0
572+
).astype(int)
573573
loss_matrix[label] = sim.map_result(on_ptc, "person", "household")
574574

575575
targets_array.append(aca_enrollment_target)
@@ -813,8 +813,10 @@ def build_loss_matrix(dataset: type, time_period):
813813
sim.calculate("state_code", map_to="household").values == row["state"]
814814
)
815815

816-
# ACA PTC amounts for every household (2025)
817-
aca_value = sim.calculate("aca_ptc", map_to="household", period=2025).values
816+
# ACA PTC amounts for every household at time_period.
817+
aca_value = sim.calculate(
818+
"aca_ptc", map_to="household", period=time_period
819+
).values
818820

819821
# Add a loss-matrix entry and matching target
820822
label = f"nation/irs/aca_spending/{row['state'].lower()}"
@@ -832,10 +834,10 @@ def build_loss_matrix(dataset: type, time_period):
832834

833835
# Flag people in households that actually receive any PTC (> 0)
834836
in_tax_unit_with_aca = (
835-
sim.calculate("aca_ptc", map_to="person", period=2025).values > 0
837+
sim.calculate("aca_ptc", map_to="person", period=time_period).values > 0
836838
)
837839
is_aca_eligible = sim.calculate(
838-
"is_aca_ptc_eligible", map_to="person", period=2025
840+
"is_aca_ptc_eligible", map_to="person", period=time_period
839841
).values
840842
is_enrolled = in_tax_unit_with_aca & is_aca_eligible
841843

@@ -860,9 +862,11 @@ def build_loss_matrix(dataset: type, time_period):
860862
state_person = sim.calculate("state_code", map_to="person").values
861863

862864
# Flag people in households that actually receive medicaid
863-
has_medicaid = sim.calculate("medicaid_enrolled", map_to="person", period=2025)
865+
has_medicaid = sim.calculate(
866+
"medicaid_enrolled", map_to="person", period=time_period
867+
)
864868
is_medicaid_eligible = sim.calculate(
865-
"is_medicaid_eligible", map_to="person", period=2025
869+
"is_medicaid_eligible", map_to="person", period=time_period
866870
).values
867871
is_enrolled = has_medicaid & is_medicaid_eligible
868872

0 commit comments

Comments
 (0)