Skip to content

[codex] Add LIHEAP targets to local calibration DB#688

Merged
MaxGhenis merged 1 commit intomainfrom
codex/liheap-db-calibration
Apr 6, 2026
Merged

[codex] Add LIHEAP targets to local calibration DB#688
MaxGhenis merged 1 commit intomainfrom
codex/liheap-db-calibration

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

@MaxGhenis MaxGhenis commented Apr 5, 2026

What changed

This PR adds LIHEAP recipient-household targets to the shared national calibration target pipeline and makes the legacy national EnhancedCPS reweighting path consume those targets from policy_data.db.

It does three things:

  • adds FY2023 and FY2024 national LIHEAP recipient-household targets to policyengine_us_data/db/etl_national_targets.py
  • extends the national target ETL so conditional targets can load non-person_count variables, which LIHEAP uses as household_count
  • adds a legacy build_loss_matrix() bridge in policyengine_us_data/utils/loss.py that reads active LIHEAP targets from storage/calibration/policy_data.db

It also clarifies in the repo docs that there are still two calibration tracks in-tree:

  • the current unified policy_data.db calibration pipeline
  • the older national-only EnhancedCPS / build_loss_matrix() path kept for legacy reproduction

Why

LIHEAP was already present in CPS/SPM reported values, but it was not represented as a calibration target in either:

  • the shared national target database pipeline, or
  • the legacy local EnhancedCPS reweighting path

That meant we could not calibrate LIHEAP recipient counts in either path, despite having CPS/SPM baseline LIHEAP receipt in the data.

Scope note

This PR calibrates LIHEAP recipient households only. It does not calibrate LIHEAP dollars.

That is intentional for now: the CPS/SPM concept is a pooled annual reported energy-assistance amount (spm_unit_energy_subsidy_reported), while LIHEAP administrative dollars are split across heating, cooling, crisis, and weatherization. Recipient-household counts are a cleaner crosswalk than national dollars.

Follow-up issue: #689 tracks options for national LIHEAP dollar targeting.

Impact

  • make database / etl_national_targets.py now loads national LIHEAP household-count targets into policy_data.db
  • local legacy build_loss_matrix() runs can pick those LIHEAP targets up from the DB when present
  • the docs now state more explicitly that target changes sometimes need to touch both calibration tracks

Validation

  • python3 -m py_compile policyengine_us_data/db/etl_national_targets.py policyengine_us_data/utils/loss.py

I also attempted:

  • python3 -m pytest tests/unit/test_etl_national_targets.py -q

That pytest invocation did not run in this shell because the environment is missing torch, which is imported from the repo test setup.

@MaxGhenis MaxGhenis force-pushed the codex/liheap-db-calibration branch from 6580abf to 0dfa53f Compare April 5, 2026 19:38
@MaxGhenis MaxGhenis marked this pull request as ready for review April 6, 2026 00:13
@MaxGhenis MaxGhenis enabled auto-merge April 6, 2026 00:13
@MaxGhenis MaxGhenis merged commit e23b696 into main Apr 6, 2026
9 checks passed
@MaxGhenis MaxGhenis deleted the codex/liheap-db-calibration branch April 6, 2026 00:15
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