Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize adjustments to baseline spending levels in reform policy #987

Merged
merged 29 commits into from
Oct 3, 2024

Conversation

jdebacker
Copy link
Member

This PR adds three new parameters to apply a proportional change to the baseline spending levels for non-pension transfers, government consumption expenditures, and infrastructure spending. These parameters are alpha_bs_T, alpha_bs_G, and alpha_bs_I, respectively.

Note that government consumption expenditures are only held at a level relative to the baseline level up until the time period the long run budget closure rule kicks in. At that point onward, government consumption expenditures are determined by the closure rule.

Addresses Issue #983.

@codecov-commenter
Copy link

codecov-commenter commented Sep 15, 2024

Codecov Report

Attention: Patch coverage is 52.63158% with 18 lines in your changes missing coverage. Please review.

Project coverage is 70.12%. Comparing base (4b32ef3) to head (4137152).
Report is 30 commits behind head on master.

Files with missing lines Patch % Lines
ogcore/SS.py 52.63% 9 Missing ⚠️
ogcore/TPI.py 0.00% 8 Missing ⚠️
ogcore/fiscal.py 90.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #987      +/-   ##
==========================================
- Coverage   70.14%   70.12%   -0.03%     
==========================================
  Files          20       20              
  Lines        5038     5047       +9     
==========================================
+ Hits         3534     3539       +5     
- Misses       1504     1508       +4     
Flag Coverage Δ
unittests 70.12% <52.63%> (-0.03%) ⬇️

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/parameters.py 83.12% <ø> (ø)
ogcore/fiscal.py 97.87% <90.00%> (-1.00%) ⬇️
ogcore/TPI.py 36.54% <0.00%> (+0.09%) ⬆️
ogcore/SS.py 71.84% <52.63%> (-0.65%) ⬇️

@jdebacker jdebacker marked this pull request as ready for review September 15, 2024 03:42
@jdebacker jdebacker changed the title Parameterize adjustments to baseline spending levels in reform policy [WIP] Parameterize adjustments to baseline spending levels in reform policy Sep 16, 2024
@jdebacker
Copy link
Member Author

Added [WIP] to title as still working on some local only tests. Will remove when they are satisfied.

@jdebacker jdebacker closed this Sep 16, 2024
@jdebacker jdebacker reopened this Sep 16, 2024
@rickecon
Copy link
Member

@jdebacker. For GH Actions tests, this PR just needs the make format command. Merging PR #971 might fix some of the local tests that are failing (see this comment).

@towashington
Copy link

Thanks, @jdebacker, @rickecon. Looking forward to using this parameter.

Is it in the road map to have this included in the next OG-Core release so the functionality can be invoked from inside OG-USA?

@rickecon
Copy link
Member

@towashington. Yes. This parameter will be able to be used in OG-USA as soon as this is incorporated into OG-Core. @jdebacker, the code looks good to me. You just need to run make format from the ogcore-dev conda environment. Then let me know when the local tests are passing.

@jdebacker
Copy link
Member Author

I've updated docs and this PR is compete. I will run the full suite of local tests when I have power and report results back here.

@rickecon
Copy link
Member

@jdebacker. I have gone through the code changes and approved them. The only further updates this PR needs are:

  • report that local tests are passing (I will start these running on my machine now)
  • update of the version to 0.13.1 in setup.py and /ogcore/__init__.py
  • update the CHANGELOG.md file (top and bottom)
  • update line 14 of pyproject.toml to target-version = ["py311", "py312"] (I noticed this in doing a search of the repo on "version")

@rickecon
Copy link
Member

@jdebacker. I ran all the local tests using your branch, and I got one failure on the last test of test_TPI.py, test_run_TPI_extra[Baseline, Kg>0]. The assert at the end was false. The traceback shows that the error was in the first set of asserts, and it looks like it is the B object (see traceback output summary below).

(ogcore-dev) richardevans@Richards-MacBook-Pro-2 OG-Core % pytest
============================= test session starts ==============================
platform darwin -- Python 3.12.6, pytest-8.3.3, pluggy-1.5.0
rootdir: /Users/richardevans/Docs/Economics/OSE/OG/OG-Core
configfile: pytest.ini
testpaths: ./tests
plugins: cov-5.0.0, anyio-4.6.0, xdist-3.6.1
collected 583 items                                                            

tests/test_SS.py ...................................                     [  6%]
tests/test_TPI.py ..........................F                            [ 10%]
tests/test_aggregates.py ........................................        [ 17%]
tests/test_basic.py ....                                                 [ 18%]
tests/test_demographics.py ................                              [ 20%]
tests/test_elliptical_u_est.py .......                                   [ 22%]
tests/test_execute.py .                                                  [ 22%]
tests/test_firm.py ..................................................... [ 31%]
................                                                         [ 34%]
tests/test_fiscal.py ......................                              [ 37%]
tests/test_household.py ................................................ [ 46%]
..                                                                       [ 46%]
tests/test_output_plots.py ............................................. [ 54%]
..                                                                       [ 54%]
tests/test_output_tables.py ..............                               [ 56%]
tests/test_parameter_plots.py ........................................   [ 63%]
tests/test_parameter_tables.py .......                                   [ 65%]
tests/test_parameters.py ..............                                  [ 67%]
tests/test_pensions.py ...............................                   [ 72%]
tests/test_run_example.py ..                                             [ 73%]
tests/test_run_ogcore.py .                                               [ 73%]
tests/test_tax.py .................................                      [ 78%]
tests/test_txfunc.py ...............................                     [ 84%]
tests/test_user_inputs.py .........                                      [ 85%]
tests/test_utils.py .................................................... [ 94%]
...............................                                          [100%]
______________________ test_run_TPI_extra[Baseline, Kg>0] ______________________
...
        for k, v in expected_dict.items():
            print("Checking ", k)
            try:
                print("Diff = ", np.absolute(test_dict[k][: p.T] - v[: p.T]).max())
>               assert np.allclose(
                    test_dict[k][: p.T], v[: p.T], rtol=1e-04, atol=1e-04
                )
E               assert False
E                +  where False = <function allclose at 0x111a7d970>(array([1.71272101, 1.72938281, 1.73864551, 1.72746434, 1.72145683,\n       1.71792535, 1.71655697, 1.71596647, 1.715334...32, 1.70702823, 1.70733347, 1.70764059, 1.70795034,\n       1.70826377, 1.70858234, 1.70890801, 1.70924351, 1.70959245]), array([1.71272101, 1.72938489, 1.73865549, 1.72748815, 1.72148578,\n       1.71794852, 1.71656468, 1.71595132, 1.715292...2 , 1.7070529 , 1.70735795, 1.70766489, 1.70797448,\n       1.70828778, 1.70860625, 1.70893187, 1.70926737, 1.70961641]), rtol=0.0001, atol=0.0001)
E                +    where <function allclose at 0x111a7d970> = np.allclose
----------------------------- Captured stdout call -----------------------------

...
Iteration: 2
	Distance: 0.4542793707203373
Max absolute value resource constraint error: 0.023755596502261347
Checking time path for violations of constraints.
Max Euler error, savings:  2.3789858971667854e-12
Max Euler error labor supply:  1.7177370637000422e-12
Checking  Y
Diff =  1.2723227424960015e-05
Checking  B
Diff =  0.00030070629741585364
=========================== short test summary info ============================
FAILED tests/test_TPI.py::test_run_TPI_extra[Baseline, Kg>0] - assert False
========= 1 failed, 582 passed, 16753 warnings in 44007.79s (12:13:27) =========

@jdebacker jdebacker changed the title [WIP] Parameterize adjustments to baseline spending levels in reform policy Parameterize adjustments to baseline spending levels in reform policy Oct 2, 2024
@jdebacker
Copy link
Member Author

@rickecon All local tests are now passing. The failure in tests/test_TPI.py::test_run_TPI_extra[Baseline, Kg>0] was due to a change in the initial value of I_g going into the transition path. Since this tests only runs TPI for two iterations, changes in the initial value can still be having an effect. The test tests/test_TPI.py::test_run_TPI_full_run[Baseline, Kg>0] uses the same parameterization, but fully solves for the equilibrium transition path and this test was unaffected by the changes in the code.

To make sure tests/test_TPI.py::test_run_TPI_extra[Baseline, Kg>0] passes, I saved a new pickle file representing the expected results given the new initial guess for I_g.

@rickecon
Copy link
Member

rickecon commented Oct 2, 2024

@jdebacker. All local tests pass on my machine (I only checked test_tpy.py::test_run_TPI_extra). I am now just waiting to get all the CI tests to pass. I am doing them one-by-one. This is frustrating when the CI tests don't just run automatically. But I will merge this as soon as I get all the tests to pass on GH Actions.

@rickecon
Copy link
Member

rickecon commented Oct 3, 2024

@jdebacker. Thanks for this. All is good. Merging now.

@rickecon rickecon merged commit 4ea91c9 into PSLmodels:master Oct 3, 2024
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.

4 participants