PolicyEngine / PolicyEngine/microcosm

Use formula-constrained leaf imputation for deduction inputs

Open
#186 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
0
Forks
4
Avg merge
1d 3h
Merged PRs (30d)
94

Description

Problem

For itemized deduction inputs, Populace should avoid using formula-owned deduction totals as exported columns, but a naive allocation from an aggregate deduction total to leaf inputs can lose important distributional information.

A concrete example is medical expenses:

  • CPS/ASEC has health-related leaves such as premiums and out-of-pocket medical expenses, including people with medical expenses who do not itemize or do not clear the federal medical deduction floor.
  • PUF has tax deduction observables such as medical expense deduction detail, but not necessarily the same underlying health leaves.
  • PolicyEngine already defines the rules engine relationship: health expense leaves -> medical_out_of_pocket_expenses -> medical_expense_deduction.

If we simply seed or split the deduction total, we miss non-itemizers and people below the threshold. If we only trust CPS leaves, we may miss the PUF-side distribution among itemizers. We need a principled bridge.

Proposal

Design a formula-constrained leaf-imputation stage, starting with medical expenses:

  1. Use CPS health leaves as the receiver/support distribution.
  2. Use the PolicyEngine rules engine to calculate formula-owned outputs from leaf candidates.
  3. Use PUF deduction observables and other predictors as donor constraints/signals.
  4. Impute or adjust the leaf inputs so the rules-engine-calculated deduction matches the donor/target information as closely as possible.
  5. Export only formula leaves; never export formula-owned deduction totals.

For medical, this could mean imputing these leaves on the PUF support side:

  • health_insurance_premiums_without_medicare_part_b
  • medicare_part_b_premiums
  • other_medical_expenses
  • possibly over_the_counter_health_expenses where relevant outside the IRS deduction

Then run PE to calculate medical_out_of_pocket_expenses and medical_expense_deduction for calibration diagnostics and target fit.

Acceptance criteria

  • No formula-owned deduction totals are emitted as stored inputs.
  • A focused test proves the stage can create positive medical leaf support for both itemizers and non-itemizers/below-floor units.
  • A diagnostic compares initial/final fit for the medical deduction target and the underlying health-leaf totals.
  • The implementation is spec-driven from the country package: country content selects sources/variables and operation type; shared runtime code performs the formula-constrained imputation.
  • The release gate distinguishes leaf-support failure from formula-output calibration failure.

Other candidate concepts

The same pattern may apply to:

  • Mortgage/itemized interest: infer structural mortgage leaves from interest deduction and housing/debt observables.
  • Charitable giving: split cash/non-cash leaves while respecting the PE charitable deduction formula and itemization limits.
  • SALT: split property tax, state income tax, and sales tax leaves while respecting the SALT deduction cap/formula.
  • QBI: infer business leaves and qualification flags from deduction and business-income observables.
  • Taxable Social Security: impute Social Security components/leaves and let PE calculate taxable Social Security rather than storing taxable totals.
  • ACA/PTC: impute take-up and plan-choice leaves, then let PE calculate PTC rather than targeting stored PTC directly.
  • EITC/CTC return-count diagnostics: materialize eligibility/claiming leaves and use PE-calculated credits/positive-credit indicators for targets.

This should be treated as a model-design issue, not a quick release blocker for the current formula-owned export assertion fix.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the current formula-owned export assertion fix and the country-package specification path. Read the PolicyEngine rules-engine relationships for the medical leaf variables, then review how shared runtime calibration and release diagnostics are structured. Done means leaf inputs support itemizers and non-itemizers, formula-owned totals are not stored, and leaf support is distinguished from formula-output calibration failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.