Skip to content

Use baseline theta#1077

Merged
rickecon merged 15 commits into
PSLmodels:masterfrom
jdebacker:reform_theta
Dec 15, 2025
Merged

Use baseline theta#1077
rickecon merged 15 commits into
PSLmodels:masterfrom
jdebacker:reform_theta

Conversation

@jdebacker

Copy link
Copy Markdown
Member

This PR updates OG-Core with a new parameter, baseline_theta. If baseline_theta=True, then the reform run uses the same replacement rate in the Social Security pension system as was computed in the baseline simulation.

@codecov-commenter

codecov-commenter commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.87097% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.92%. Comparing base (cb0e9df) to head (f9e34c1).
⚠️ Report is 131 commits behind head on master.

Files with missing lines Patch % Lines
ogcore/SS.py 27.02% 27 Missing ⚠️
ogcore/TPI.py 0.00% 14 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1077      +/-   ##
==========================================
- Coverage   72.92%   72.92%   -0.01%     
==========================================
  Files          21       21              
  Lines        5090     5122      +32     
==========================================
+ Hits         3712     3735      +23     
- Misses       1378     1387       +9     
Flag Coverage Δ
unittests 72.92% <33.87%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
ogcore/__init__.py 100.00% <100.00%> (ø)
ogcore/pensions.py 68.34% <100.00%> (+0.46%) ⬆️
ogcore/TPI.py 33.48% <0.00%> (-0.94%) ⬇️
ogcore/SS.py 81.01% <27.02%> (+1.38%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jdebacker jdebacker marked this pull request as ready for review December 4, 2025 01:38
@rickecon

rickecon commented Dec 4, 2025

Copy link
Copy Markdown
Member

@jdebacker. I have reviewed and approved this PR. I will merge it as soon as all the tests pass.

@rickecon

rickecon commented Dec 4, 2025

Copy link
Copy Markdown
Member

@jdebacker. This breaks when doing the reform simulation. I got the following traceback after a run finished the baseline TPI solution and moved to the reform SS solution.

File "/opt/anaconda3/envs/ss-maxben-j-dev/lib/python3.13/site-packages/ogcore/SS.py", line 66, in euler_equation_solver
    error1 = household.FOC_savings(
        r,
    ...<17 lines>...
        "SS",
    )
  File "/opt/anaconda3/envs/ss-maxben-j-dev/lib/python3.13/site-packages/ogcore/household.py", line 494, in FOC_savings
    taxes = tax.net_taxes(
        r,
    ...<14 lines>...
        p,
    )
  File "/opt/anaconda3/envs/ss-maxben-j-dev/lib/python3.13/site-packages/ogcore/tax.py", line 285, in net_taxes
    pension = pensions.pension_amount(
        r, w, n, 1, theta, t, j, shift, method, e, factor, p
    )
  File "/opt/anaconda3/envs/ss-maxben-j-dev/lib/python3.13/site-packages/ogcore/pensions.py", line 98, in pension_amount
    pension = SS_amount(w, n, theta, t, j, shift, method, e, p)
  File "/opt/anaconda3/envs/ss-maxben-j-dev/lib/python3.13/site-packages/ogcore/pensions.py", line 159, in SS_amount
    pension[p.retire[-1] :] = replace_rate_adjust * theta * w
    ~~~~~~~^^^^^^^^^^^^^^^^
ValueError: could not broadcast input array from shape (7,) into shape (36,)

@jdebacker

Copy link
Copy Markdown
Member Author

@rickecon Good catch on the error above. I fixed the case for baseline_theta=True and j not None in pensions.replacement_rate_vals. I also added a test to cover this case.

@jdebacker

Copy link
Copy Markdown
Member Author

All tests pass locally:

tests/test_SS.py ...........................                             [  4%]
tests/test_TPI.py ...........................                                                       [  9%]
tests/test_aggregates.py .........................................                                  [ 16%]
tests/test_basic.py ....                                                                            [ 16%]
tests/test_demographics.py ................                                                         [ 20%]
tests/test_elliptical_u_est.py .......                                                              [ 21%]
tests/test_execute.py .                                                                             [ 21%]
tests/test_firm.py .....................................................................                                                                                    [ 33%]
tests/test_fiscal.py ......................                                                         [ 37%]
tests/test_household.py ..................................................                                                                                                  [ 45%]
tests/test_output_plots.py ...............................................                                                                                                  [ 53%]
tests/test_output_tables.py ..............                                                          [ 56%]
tests/test_parameter_plots.py ........................................                              [ 62%]
tests/test_parameter_tables.py .......                                                              [ 64%]
tests/test_parameters.py ..............                                                             [ 66%]
tests/test_pensions.py .................................                                            [ 71%]
tests/test_run_example.py ..                                                                        [100%]
tests/test_run_ogcore.py .                                                                          [100%]
tests/test_tax.py ...................................                                               [100%]
tests/test_txfunc.py ..............................                                                 [100%]
tests/test_user_inputs.py .........                                                                 [100%]
tests/test_utils.py ...................................................................................                                                                                       [100%]

@rickecon

Copy link
Copy Markdown
Member

@jdebacker. I pulled this branch, updated the conda environment, and ran the run_ogcore_example.py script. Script ran smoothly through all phases of baseline and reform, steady state and time path. I am merging this.

@rickecon rickecon merged commit 83227e3 into PSLmodels:master Dec 15, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants