Apply replacement_rate_adjust to every pension system - #1201
Apply replacement_rate_adjust to every pension system#1201marcelolafleur wants to merge 2 commits into
Conversation
55838c9 to
ed31a6d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1201 +/- ##
==========================================
+ Coverage 72.74% 72.78% +0.03%
==========================================
Files 22 22
Lines 5768 5783 +15
==========================================
+ Hits 4196 4209 +13
- Misses 1572 1574 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
arihantlodha-cmd
left a comment
There was a problem hiding this comment.
Nice, this is a clean fix for a genuinely sneaky bug. A parameter that silently does nothing under three of the four systems, with no warning, is exactly the kind of thing that bites someone quietly.
I'm still newer here so treat this as non-blocking, but I traced the indexing since that's the load-bearing claim. The helper matches SS_amount row for row: SS uses adjust[-1], the 1-D time-path case uses adjust[t], and the 2-D case's adjust[t:t+length] is exactly the t + tt per-cohort rows SS_amount loops over at line 70. So the "mirrors SS_amount" claim holds. And nice that you tested both halves: one test that the adjustment actually applies under every system, and a separate one that pins the per-cohort offset directly, which is the part most likely to hide an off-by-one.
One thing worth making explicit. The helper multiplies the whole pension array, whereas SS_amount only touches pension[retireTPI:]. Those are equivalent only because DB/NDC/PS return zero benefits before retirement, so scaling the zeros is harmless. That holds today, but it's an implicit assumption a future pension formula could break. A one-line comment, or an assert in the test that the pre-retirement entries stay zero, would keep that from quietly going wrong.
Minor: TPI_scalar returns adjust[0, j], the first year. Is row 0 the intended year for the scalar case, or should it track the period being computed like the other branches?
Thanks for catching this one.
|
Thanks @arihantlodha-cmd, good catch on the implicit assumption. I added a note to the helper's docstring: scaling the whole array only works because DB, NDC, and PS pay nothing before retirement, and a future system that pays earlier would need the SS_amount treatment. On TPI_scalar: row 0 is intended. That branch exists for exactly one caller, firstdoughnutring, which handles one special household: the oldest person alive when the transition begins, who has just one period left to live. Their entire remaining problem happens in year 0, by construction, so row 0 is always the right row. It also matches what SS_amount already does for this case. |
|
thanks @marcelolafleur, the docstring note is exactly the right guard. and the TPI_scalar explanation clicks: if firstdoughnutring's one household has a single period left and lives it entirely in year 0, then row 0 is unambiguous by construction. looks good to me. |
Fixes #1200.
replacement_rate_adjustis a table of multipliers on pension benefits, one per year and income group. It lets a country phase benefits down over time.It was only read inside
SS_amount, so it worked under US-Style Social Security and did nothing at all under Defined Benefits, Notional Defined Contribution and Points System. Setting it under those three changed nothing and gave no warning.pension_amountnow applies it to the other three systems as well.The only fiddly part is looking up the right year. In the steady state there is one year, so the multiplier is the last row of the table. Along the transition the model computes a block of years at once, and each row of that block is a different year — the block starts at year
t, so its first row needs the multiplier for yeart, its second row yeart + 1, and so on. A small helper does that lookup and returns the multipliers shaped to line up with the benefits array. This is whatSS_amountwas already doing for US-Style; the helper does the same for the rest.SS_amountitself is unchanged, so US-Style results cannot move.With this fix, thame call, with the multiplier halved:
Tests
test_replacement_rate_adjust_applies_to_every_system: halving the multiplier must halve benefits, under all four systems. Fails on master for DB, NDC and PS.test_replacement_rate_adjustment_indexes_by_cohort_year: checks the year lookup: on the transition, row n of the block must get the multiplier for yeart + n, and the steady state must get the last row. Using one year's multiplier for the whole block would still pass a test with a flat table, and would quietly cancel out a phase-down. The existingtest_pension_amountsets the table to all ones, so it cannot catch this.test_pensions.py,test_tax.pyandtest_aggregates.pypass, 122 total.cc: @jdebacker @rickecon