Fix LSR and CG behavioral responses compounding when combined#7788
Open
MaxGhenis wants to merge 3 commits intoPolicyEngine:mainfrom
Open
Fix LSR and CG behavioral responses compounding when combined#7788MaxGhenis wants to merge 3 commits intoPolicyEngine:mainfrom
MaxGhenis wants to merge 3 commits intoPolicyEngine:mainfrom
Conversation
When both labor supply responses (LSR) and capital gains (CG) behavioral responses were enabled simultaneously, they created nested simulation branches that compounded each other's effects, producing nonsensical results (e.g. $8.6T tax impact instead of ~$40B). The fix neutralizes CG responses in LSR measurement branches and LSR responses in CG measurement branches, making each response measured against static (no-behavioral-response) income. The responses are now additive rather than compounding. Fixes PolicyEngine#7785. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The test requires ~60 minutes for 3 full microsimulations. Skip unless RUN_HEAVY_TESTS=1 is set. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7788 +/- ##
============================================
- Coverage 100.00% 77.46% -22.54%
============================================
Files 3 2 -1
Lines 33 71 +38
Branches 0 3 +3
============================================
+ Hits 33 55 +22
- Misses 0 14 +14
- Partials 0 2 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The parametric reform test passes with the neutralization fix, but the WATCA structural reform (which overrides taxable_income and income_tax_before_credits) still produces $8.6T. Split into two tests to cover both cases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #7785 — when both labor supply responses (LSR) and capital gains (CG) behavioral responses were enabled simultaneously, they created nested simulation branches that compounded each other, producing nonsensical results.
Root cause: LSR measurement branches didn't neutralize
capital_gains_behavioral_response, and CG measurement branches didn't neutralizeemployment_income_behavioral_response/self_employment_income_behavioral_response. This caused each response to fire inside the other's measurement branches with wrong inputs, creating a positive feedback loop.Fix: Each behavioral response's measurement branches now neutralize all OTHER behavioral responses, making the responses additive (measured against static income) rather than compounding.
Before fix (WATCA reform, 2026):
After fix (top bracket +10pp, 2026):
Combined impact is now 0.3x the sum of individual impacts (bounded and reasonable) vs ~200x before.
Test plan
python /tmp/test_lsr_cg_fix.pypasses with fix (combined/sum ratio = 0.3x)