Skip to content

Make interest rate on government debt a function of the debt to GDP ratio#1037

Merged
rickecon merged 49 commits intoPSLmodels:masterfrom
jdebacker:debt_gdp
Jan 22, 2026
Merged

Make interest rate on government debt a function of the debt to GDP ratio#1037
rickecon merged 49 commits intoPSLmodels:masterfrom
jdebacker:debt_gdp

Conversation

@jdebacker
Copy link
Member

@jdebacker jdebacker commented Jun 25, 2025

Since the risk premium of governments may vary with the amount of debt they accumulate, this PR updates the fiscal.get_r_gov function to allow it to vary with the debt to GDP ratio in a quadratic manner. The new specification adds to parameters to the function determining r_gov. The new function is:
$r_{gov,t}= (1-\tau_{d,t})r_{t} - \mu_d + \beta_1 \frac{D_t}{Y_t} + \beta_2 \left(\frac{D_t}{Y_t}\right)^2$

In the code $\beta_1$ maps to r_gov_DY and $\beta_2$ maps to r_gov_DY2 to avoid confusion with the rate of time preference.

@codecov-commenter
Copy link

codecov-commenter commented Jun 26, 2025

Codecov Report

❌ Patch coverage is 60.86957% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.01%. Comparing base (8cf609a) to head (bc9dc7a).

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1037      +/-   ##
==========================================
- Coverage   73.19%   73.01%   -0.19%     
==========================================
  Files          21       21              
  Lines        5137     5143       +6     
==========================================
- Hits         3760     3755       -5     
- Misses       1377     1388      +11     
Flag Coverage Δ
unittests 73.01% <60.86%> (-0.19%) ⬇️

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

Files with missing lines Coverage Δ
ogcore/SS.py 78.80% <100.00%> (-2.21%) ⬇️
ogcore/__init__.py 100.00% <100.00%> (ø)
ogcore/fiscal.py 97.97% <100.00%> (+0.10%) ⬆️
ogcore/TPI.py 33.55% <0.00%> (-0.08%) ⬇️
🚀 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 June 26, 2025 15:46
@jdebacker
Copy link
Member Author

@rickecon, This PR is ready for your review.

@rickecon
Copy link
Member

@jdebacker. Thanks for submitting this PR. Great update. Here is one suggestion and two questions.

  • This is a relatively small addition to OG-Core. I recommend that this be a patch version update to 0.14.5, rather than a minor version update to 0.15.0 (see Semantic Versioning).
  • In your fiscal.py, the get_r_gov() function takes DY_ratio as an argument. Why in your TPI.py in line 707 does r_gov take 0 as the DY_ratio value?
  • Have you run an example locally with r_gov_DY>0 and r_gov_DY2>0?

ogcore/TPI.py Outdated

# Compute other interest rates
r_gov = fiscal.get_r_gov(r, p, "TPI")
r_gov = fiscal.get_r_gov(r, 0, p, "TPI")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdebacker. Why is the DY_ratio argument in this line equal to 0? You have the D and the Y series above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this to take the initial guess at the debt to GDP path (although since these are initial guesses, they shouldn't affect the model solution, but make affect the time to convergence).

@jdebacker
Copy link
Member Author

Still a couple tests that I expect to pass failing locally:

FAILED tests/test_TPI.py::test_run_TPI_full_run[Baseline] - assert False
FAILED tests/test_TPI.py::test_run_TPI_full_run[Baseline, delta_tau = 0] - assert False

In both cases, it's a diff in bmat_splus1 (much larger in the $\delta_\tau$ = 0 case)

@jdebacker jdebacker changed the title [WIP] Make interest rate on government debt a function of the debt to GDP ratio Make interest rate on government debt a function of the debt to GDP ratio Jan 20, 2026
@jdebacker
Copy link
Member Author

All tests pass locally:

tests/test_SS.py .........................................               [  6%]
tests/test_TPI.py ......................                                 [ 10%]
tests/test_aggregates.py .........................................       [ 17%]
tests/test_basic.py ....                                                 [100%]
tests/test_demographics.py ................                              [100%]
tests/test_elliptical_u_est.py .......                                   [100%]
tests/test_execute.py .                                                  [100%]
tests/test_firm.py ..................................................... [ 76%]
................                                                         [100%]
tests/test_fiscal.py .........................                           [100%]
tests/test_household.py ................................................ [ 94%]
...                                                                      [100%]
tests/test_output_plots.py ............................................. [ 95%]
..                                                                       [100%]
tests/test_output_tables.py ..............                               [100%]
tests/test_parameter_plots.py ........................................   [100%]
tests/test_parameter_tables.py .......                                   [100%]
tests/test_parameters.py ..............                                  [100%]
tests/test_pensions.py .................................                 [100%]
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 .................................................... [ 62%]
...............................                                          [100%]

@rickecon This PR is ready for review.

@rickecon
Copy link
Member

@jdebacker. I don't understand the 4 errors in test_fiscal.py. They are all "ValueError: assignment destination is read-only". It looks like we are writing to a NumPy array that is read only. But I don't understand why it would be read only.

@jdebacker
Copy link
Member Author

@rickecon I see the issue, Pandas 3.0.0 (released yesterday) now treats Numpy arrays created from df.values as readonly. Will update to make these arrays from copies.

@rickecon
Copy link
Member

@jdebacker. This looks great. Thanks for adding those .copy() commands in test_fiscal.py. Merging.

@rickecon rickecon merged commit dd21944 into PSLmodels:master Jan 22, 2026
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