PolicyEngine / PolicyEngine/policyengine-us

`sim.calc("household_income_decile", map_to="tax_unit").unique()` returns non-integer values

Open
#4,309 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
163
Forks
213
Avg merge
3d 3h
Merged PRs (30d)
96

Description

See [this notebook](https://colab.research.google.com/drive/15-7gAozQ9-gH-YvGpjAWYCVVb_-NJwd6#scrollTo=cIz_kXelfPuK):
```python
from policyengine_us import Microsimulation

sim = Microsimulation()

sim.calc("household_income_decile").unique()
```
returns ints from 1 to 10 (plus -1 for negative income) as expected, but:
```python
sim.calc("household_income_decile", map_to="tax_unit").unique()
```
returns non-integer values between 1 and 10.

I would have expected it to just project the household attribute down to the tax unit. Does it instead divide by people and then aggregate to tax units? Should we define it as an enum instead if we want it projected? @nikhilwoodruff

Contributor guide

Open the contributing guide

Research direction

Reproduce the two `Microsimulation.calc` calls from the linked notebook and compare their unique values. Trace the definition of `household_income_decile` and the `map_to="tax_unit"` behavior to determine whether the value should be projected or aggregated; done means the tax-unit result follows the intended integer decile semantics and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.