-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Bug
The intra_decile_impact and intra_wealth_decile_impact functions in policyengine/outputs/macro/comparison/calculate_economy_comparison.py double-count income changes when computing percentage change.
The buggy calculation:
absolute_change = (reform_income - baseline_income).values
capped_baseline_income = np.maximum(baseline_income.values, 1)
capped_reform_income = np.maximum(reform_income.values, 1) + absolute_change
income_change = (capped_reform_income - capped_baseline_income) / capped_baseline_incomereform_income already reflects the change relative to baseline_income, so adding absolute_change again to capped_reform_income doubles the effective percentage change. This causes households with a true 4% gain to appear as 8%, pushing them into the wrong bucket (>5% instead of <5%).
Fix
Replace with:
absolute_change = reform_values - baseline_values
capped_baseline = np.maximum(baseline_values, 1)
income_change = absolute_change / capped_baselineThis mirrors the fix applied in policyengine-api (PR PolicyEngine/policyengine-api#3283).
Scope
intra_decile_impactintra_wealth_decile_impact- Both on the
0.xmaintenance branch
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels