Program statistics count every unchanged tax unit as both a winner and a loser

Open Beginner friendly
#771 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
data

Research direction

Read src/policyengine/outputs/program_statistics.py, especially the ChangeAggregate thresholds in ProgramStatistics.run(). Add or update a test covering an unchanged tax and check that it yields zero winners and zero losers. The issue is done when tax winner and loser thresholds match the suggested directions and the regression test passes.

Written by the indexing model from the issue text.

Description

Filed by Claude Code for Max.

ProgramStatistics.run() inverts the winners and losers thresholds for taxes, so every unit whose tax doesn't change counts as both a winner and a loser.

src/policyengine/outputs/program_statistics.py on main (lines 85–103; the same in 6.20.3):

winners = ChangeAggregate(..., change_geq=0.01 if not self.is_tax else -0.01)
losers = ChangeAggregate(..., change_leq=-0.01 if not self.is_tax else 0.01)

For a tax, change >= -0.01 keeps every unit whose tax stayed the same or rose, and change <= 0.01 keeps every unit whose tax stayed the same or fell.

What it prints. With 6.20.3 and the default US dataset, pe.us.economic_impact_analysis for a single filer standard deduction of $30,950 in 2026 gives these rows:

program_name change winners losers
income_tax -9.149107e+10 1.159564e+08 1.644485e+08
employee_payroll_tax 0 1.653825e+08 1.653825e+08

The payroll tax doesn't change, yet every unit counts as both a winner and a loser. Income tax falls, yet more units count as losers than winners. The UK example on policyengine.org/uk/python shows the same pattern for national_insurance: 7.120972e+07 winners and 7.120972e+07 losers at zero change.

Suggested fix. For a tax, count winners as change <= -0.01 and losers as change >= 0.01. Add a test in which an unchanged tax yields zero winners and zero losers.

PolicyEngine/household-api-docs#28 stops showing these two columns in the US examples on /us/python until a fix ships.

🤖 Generated with Claude Code

Dominant language
Python
Stars
10
Forks
10
Avg merge
2d 2h
Merged PRs (30d)
16

Getting set up

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.

More from PolicyEngine/policyengine.py

All issues in PolicyEngine/policyengine.py

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.