From 46a21151bde4748dda10186bceb609d0954c55e9 Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Thu, 12 Nov 2026 12:49:21 -0500 Subject: [PATCH 1/6] Add concessional (ODA) government debt at its own interest rate (Issue #1125) --- CHANGELOG.md | 10 ++ docs/book/content/api/fiscal.rst | 2 +- docs/book/content/intro/parameters.md | 14 ++ docs/book/content/theory/government.md | 25 +++- docs/book/content/theory/market_clearing.md | 6 +- docs/book/content/theory/stationarization.md | 16 +- ogcore/SS.py | 22 ++- ogcore/TPI.py | 12 +- ogcore/__init__.py | 2 +- ogcore/default_parameters.json | 48 ++++++ ogcore/fiscal.py | 70 +++++++++ ogcore/parameters.py | 10 ++ pyproject.toml | 2 +- tests/test_SS.py | 54 +++++++ tests/test_fiscal.py | 145 +++++++++++++++++++ tests/test_parameters.py | 21 +++ uv.lock | 2 +- 17 files changed, 435 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3130c8acd..6f3da474c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.25.0] - 2026-11-12 + +### Adds +- Adds concessional government debt owed to official foreign lenders (official development assistance loans), addressing Issue #1125. The new time-varying parameter `alpha_ODA` (default 0.0) sets the stock of this debt as a share of GDP, and `r_ODA_annual` (default 0.0, time varying, converted to a model-period rate `r_ODA`) its real interest rate. Each period the government receives the new concessional borrowing and pays its interest, in the budget constraint of the steady state and the time path (`fiscal.D_G_path`, `fiscal.get_G_ss`, and the balanced-budget case of `fiscal.get_TR`), and the interest is paid abroad at `r_ODA` in the resource constraint, alongside the foreign-held market debt. Concessional debt is separate from the market debt `D`: it is not held by households, so it does not enter the portfolio return `r_p`, and `r_gov`, `debt_ratio_ss` and the closure rule, and `zeta_D` refer to market debt. +- Adds `fiscal.get_ODA`, which returns the stock of concessional debt, new concessional borrowing, and its interest in the steady state or along the time path. +- Adds `D_ODA`, `new_borrowing_ODA`, and `debt_service_ODA` to the steady-state and time-path output, and includes concessional interest in `total_government_outlays`. +- Adds concessional debt to the government budget constraint, the budget closure rules, and their stationarized forms in the documentation, and adds concessional debt and foreign aid to the goods market clearing condition. +- Adds tests of `fiscal.get_ODA`, of the steady-state spending and the time path of debt and spending with concessional debt (the budget constraint holds each period), of the new parameters, and a steady-state solution with concessional debt that balances the budget and clears the goods market. + ## [0.24.4] - 2026-11-07 ### Adds @@ -872,6 +881,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Any earlier versions of OG-USA can be found in the [`OG-Core`](https://github.com/PSLmodels/OG-Core) repository [release history](https://github.com/PSLmodels/OG-Core/releases) from [v.0.6.4](https://github.com/PSLmodels/OG-Core/releases/tag/v0.6.4) (Jul. 20, 2021) or earlier. +[0.25.0]: https://github.com/PSLmodels/OG-Core/compare/v0.24.4...v0.25.0 [0.24.4]: https://github.com/PSLmodels/OG-Core/compare/v0.24.3...v0.24.4 [0.24.3]: https://github.com/PSLmodels/OG-Core/compare/v0.24.2...v0.24.3 [0.24.2]: https://github.com/PSLmodels/OG-Core/compare/v0.24.1...v0.24.2 diff --git a/docs/book/content/api/fiscal.rst b/docs/book/content/api/fiscal.rst index a8fc50f0b..c0a9ad2be 100644 --- a/docs/book/content/api/fiscal.rst +++ b/docs/book/content/api/fiscal.rst @@ -10,4 +10,4 @@ ogcore.fiscal .. automodule:: ogcore.fiscal :members: D_G_path, get_D_ss, get_G_ss, get_debt_service_f, get_TR, - get_r_gov, get_I_g, get_foreign_aid, get_K_g + get_r_gov, get_I_g, get_foreign_aid, get_ODA, get_K_g diff --git a/docs/book/content/intro/parameters.md b/docs/book/content/intro/parameters.md index 398c06d67..b930dc8f5 100644 --- a/docs/book/content/intro/parameters.md +++ b/docs/book/content/intro/parameters.md @@ -304,6 +304,20 @@ _Valid Range:_ min = 0.0 and max = 1.0 _Out-of-Range Action:_ error +#### `alpha_ODA` +_Description:_ Stock of government debt owed to official foreign lenders on concessional terms (e.g., official development assistance loans from multilateral and bilateral lenders), as a share of GDP. This debt is held entirely by foreigners, pays the interest rate r_ODA_annual, and is separate from the market debt D whose path the budget closure rule targets. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered. +_Value Type:_ float +_Valid Range:_ min = 0.0 and max = 3.0 +_Out-of-Range Action:_ error + + +#### `r_ODA_annual` +_Description:_ Annual real interest rate paid on government debt owed to official foreign lenders on concessional terms (alpha_ODA). Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered. +_Value Type:_ float +_Valid Range:_ min = -0.2 and max = 0.2 +_Out-of-Range Action:_ error + + ### Government Pension Parameters #### `retirement_age` diff --git a/docs/book/content/theory/government.md b/docs/book/content/theory/government.md index 8cff4df34..da6250ea7 100644 --- a/docs/book/content/theory/government.md +++ b/docs/book/content/theory/government.md @@ -695,11 +695,11 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul (SecUnbalGBCbudgConstr)= ## Government Budget Constraint - Let the level of government debt in period $t$ be given by $D_t$. The government budget constraint requires that government revenue $Rev_t$, external foreign assistance, $FA_t$, plus the budget deficit ($D_{t+1} - D_t$) equal expenditures on interest on the debt, government spending on public goods $G_t$, total infrastructure investments $I_{g,t}$, total pension outlays, total transfer payments to households $TR_t$, and $UBI_t$ every period $t$, + Let the level of government debt in period $t$ be given by $D_t$. The government may also owe concessional debt $D^{ODA}_t$ to official foreign lenders, described below. The government budget constraint requires that government revenue $Rev_t$, external foreign assistance, $FA_t$, plus the budget deficit financed by new borrowing ($D_{t+1} - D_t$ and $D^{ODA}_{t+1} - D^{ODA}_t$) equal expenditures on interest on the debt, government spending on public goods $G_t$, total infrastructure investments $I_{g,t}$, total pension outlays, total transfer payments to households $TR_t$, and $UBI_t$ every period $t$, ```{math} :label: EqUnbalGBCbudgConstr - D_{t+1} + Rev_t + FA_t = (1 + r_{gov,t})D_t + G_t + I_{g,t} + Pensions_t + TR_t + UBI_t \quad\forall t + D_{t+1} + D^{ODA}_{t+1} + Rev_t + FA_t = (1 + r_{gov,t})D_t + (1 + r_{ODA,t})D^{ODA}_t + G_t + I_{g,t} + Pensions_t + TR_t + UBI_t \quad\forall t ``` where $r_{gov,t}$ is the interest rate paid by the government defined in equation {eq}`EqUnbalGBC_rate_wedge` below, $G_{t}$ is government spending on public goods, $I_{g,t}$ is total government spending on infrastructure investment, $TR_{t}$ are non-pension government transfers, and $UBI_t$ is the total UBI transfer outlays across households in time $t$. All variables in {eq}`EqUnbalGBCbudgConstr` are real variables denominated in units of current-period output in industry $M$ the numeraire ($p_{M,t}=1$ for all $t$). @@ -736,6 +736,15 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul where $\delta_g$ is the depreciation rate on infrastructure and $\phi_g$ (`infra_investment_leakage_rate`) is the fraction of infrastructure investment lost to leakage (e.g., corruption or other frictions). The stock of public capital in each industry $m$ complements labor and private capital in the production function of the representative firm, in Equation {eq}`EqFirmsCESprodfun`. + Many low-income countries borrow from official lenders, such as multilateral development banks and bilateral donors, on concessional terms: at interest rates well below market rates, in amounts the lenders decide. `OG-Core` models this concessional debt (official development assistance loans) as a stock $D^{ODA}_t$ held entirely by foreigners, set as a time-dependent fraction $\alpha_{ODA,t}$ (`alpha_ODA`) of GDP and paying the exogenous real interest rate $r_{ODA,t}$ (`r_ODA_annual`, converted to a model-period rate). + + ```{math} + :label: EqUnbalGBC_ODA + D^{ODA}_t = \alpha_{ODA,t}\: Y_t \quad\forall t + ``` + + The government receives the new concessional borrowing $D^{ODA}_{t+1} - D^{ODA}_t$ and pays the interest $r_{ODA,t}D^{ODA}_t$ each period. Concessional debt is separate from the market debt $D_t$: it is not part of household savings, so it does not enter the household portfolio return $r_{p,t}$ in {eq}`eq_portfolio_return`, and the interest rate $r_{gov,t}$, the debt-to-GDP target $\alpha_D$ of the budget closure rule, and the share of new debt bought by foreigners $\zeta_D$ all refer to market debt. Its interest is paid abroad at $r_{ODA,t}$ in the goods market clearing condition (Chapter {ref}`Chap_MarkClr`). By default $\alpha_{ODA,t} = 0$. + Aggregate spending on UBI at time $t$ is the sum of UBI payments across all households at time $t$: ```{math} @@ -793,8 +802,8 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul &\text{where}\quad g_{g,t} = \begin{cases} 1 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\:\text{if}\quad t < T_{G1} \\ - \frac{\left[\rho_{d}\alpha_{D}Y_{t} + (1-\rho_{d})D_{t}\right] - (1+r_{gov,t})D_{t} - I_{g,t} - TR_{t} - UBI_{t} + Rev_{t} + FA_{t}}{\alpha_g Y_t} \quad\text{if}\quad T_{G1}\leq t= p.tG1) and (t < p.tG2): @@ -129,6 +140,7 @@ def D_G_path(r, dg_fixed_values, p): - (1 + r_gov[t]) * D[t] + total_tax_revenue[t] + foreign_aid[t] + + ODA_net[t] - agg_pension_outlays[t] - I_g[t - 1] - TR[t] @@ -140,6 +152,7 @@ def D_G_path(r, dg_fixed_values, p): - (1 + r_gov[t]) * D[t] + total_tax_revenue[t] + foreign_aid[t] + + ODA_net[t] - agg_pension_outlays[t] - I_g[t - 1] - TR[t] @@ -159,6 +172,7 @@ def D_G_path(r, dg_fixed_values, p): + agg_pension_outlays[t - 1] - total_tax_revenue[t - 1] - foreign_aid[t - 1] + - ODA_net[t - 1] ) r_gov[t] = get_r_gov(r[t], D[t] / Y[t], p, method="scalar", t=t) G[t] = ( @@ -166,6 +180,7 @@ def D_G_path(r, dg_fixed_values, p): - (1 + r_gov[t]) * D[t] + total_tax_revenue[t] + foreign_aid[t] + + ODA_net[t] - agg_pension_outlays[t] - I_g[t - 1] - TR[t] @@ -180,6 +195,7 @@ def D_G_path(r, dg_fixed_values, p): + agg_pension_outlays[t] - total_tax_revenue[t] - foreign_aid[t] + - ODA_net[t] ) D_ratio_max = np.amax(D[: p.T] / Y[: p.T]) print("Maximum debt ratio: ", D_ratio_max) @@ -276,6 +292,8 @@ def get_G_ss( .. math:: \bar{G} = \bar{Rev} + \overline{FA} + \bar{D}\bigl[(1 + \bar{g}_n)e^{g_y} - (1 + \bar{r}_{gov})\bigr] + + \bar{D}^{ODA}\bigl[(1 + \bar{g}_n)e^{g_y} + - (1 + \bar{r}_{ODA})\bigr] - \bar{I}_g - \bar{TR} - \overline{UBI} Args: @@ -298,10 +316,13 @@ def get_G_ss( if p.budget_balance: G = p.alpha_G[-1] * Y else: + _, new_borrowing_ODA, debt_service_ODA = get_ODA(Y, p, "SS") G = ( total_tax_revenue + new_borrowing + foreign_aid + + new_borrowing_ODA + - debt_service_ODA - (agg_pension_outlays + TR + debt_service + UBI_outlays + I_g) ) @@ -370,9 +391,12 @@ def get_TR( """ if p.budget_balance: + _, new_borrowing_ODA, debt_service_ODA = get_ODA(Y, p, method) new_TR = ( total_tax_revenue + foreign_aid + + new_borrowing_ODA + - debt_service_ODA - agg_pension_outlays - G - UBI_outlays @@ -503,6 +527,52 @@ def get_foreign_aid(Y, FA_baseline, p, method="SS"): return foreign_aid +def get_ODA(Y, p, method="SS"): + r""" + Find the stock of concessional government debt held by official + foreign lenders, the new concessional borrowing, and its interest. + + .. math:: + \begin{split} + \hat{D}^{ODA}_{t} &= \alpha_{ODA,t}\hat{Y}_{t} \\ + \text{new ODA borrowing}_t &= e^{g_y}\left(1 + + \tilde{g}_{n,t+1}\right)\hat{D}^{ODA}_{t+1} - + \hat{D}^{ODA}_{t} \\ + \text{ODA debt service}_t &= r_{ODA,t}\hat{D}^{ODA}_{t} + \end{split} + + Args: + Y (array_like): aggregate output + p (OG-Core Specifications object): model parameters + method (str): either 'SS' for steady-state or 'TPI' for transition + path + + Returns: + (tuple): concessional debt variables: + + * D_ODA (array_like): stock of concessional debt + * new_borrowing_ODA (array_like): new concessional borrowing + * debt_service_ODA (array_like): interest on concessional debt + """ + if method == "SS": + D_ODA = p.alpha_ODA[-1] * Y + new_borrowing_ODA = D_ODA * ((1 + p.g_n_ss) * np.exp(p.g_y) - 1) + debt_service_ODA = p.r_ODA[-1] * D_ODA + else: + # The stock in period T needs output in period T, beyond the + # path; output is at its steady state by then, so carry the + # last value forward. + Y_path = np.append(Y[: p.T], Y[p.T - 1]) + D_ODA = p.alpha_ODA[: p.T + 1] * Y_path + new_borrowing_ODA = ( + D_ODA[1:] * np.exp(p.g_y) * (1 + p.g_n[: p.T]) - D_ODA[:-1] + ) + D_ODA = D_ODA[:-1] + debt_service_ODA = p.r_ODA[: p.T] * D_ODA + + return D_ODA, new_borrowing_ODA, debt_service_ODA + + def get_K_g(K_g0, I_g, p, method): r""" Law of motion for the government capital stock diff --git a/ogcore/parameters.py b/ogcore/parameters.py index 05e52fad9..33ffcd1a1 100644 --- a/ogcore/parameters.py +++ b/ogcore/parameters.py @@ -252,11 +252,13 @@ def compute_default_params(self): "alpha_T", "alpha_I", "alpha_FA", + "alpha_ODA", "alpha_bs_G", "alpha_bs_T", "alpha_bs_I", "alpha_bs_FA", "world_int_rate_annual", + "r_ODA_annual", "adjustment_factor_for_cit_receipts", "tau_bq", "h_wealth", @@ -443,6 +445,14 @@ def compute_default_params(self): self.S, ) + # interest rate on concessional (ODA) government debt + self.r_ODA = rate_conversion( + self.r_ODA_annual, + self.starting_age, + self.ending_age, + self.S, + ) + # expand the cohort-specific pension parameters (retirement age # and the DB and NDC system parameters) to arrays by period and # age, and set the period of retirement, retire diff --git a/pyproject.toml b/pyproject.toml index 2b42c273e..64714ab78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ogcore" -version = "0.24.4" +version = "0.25.0" authors = [ {name = "Jason DeBacker and Richard W. Evans"}, ] diff --git a/tests/test_SS.py b/tests/test_SS.py index 00d7a8b6b..2146efab8 100644 --- a/tests/test_SS.py +++ b/tests/test_SS.py @@ -447,6 +447,60 @@ def test_SS_solver(baseline, param_updates, filename, dask_client): ) +def test_SS_solver_ODA(dask_client): + # With concessional (ODA) debt, the steady state holds the stock at + # its share of GDP, balances the government budget with the ODA flows, + # and clears the goods market with ODA interest paid abroad. + p = Specifications(baseline=True, num_workers=NUM_WORKERS) + p.update_specifications({"alpha_ODA": [0.3], "r_ODA_annual": [0.01]}) + p.frac_tax_payroll = np.zeros(p.frac_tax_payroll.shape) + p.output_base = CUR_PATH + b_guess = np.ones((p.S, p.J)) * 0.07 + n_guess = np.ones((p.S, p.J)) * 0.35 * p.ltilde + rguess = 0.06483431412921253 + wguess = firm.get_w_from_r(rguess, p, "SS") + BQguess = aggregates.get_BQ(rguess, b_guess, None, p, "SS", False) + ss = SS.SS_solver( + b_guess, + n_guess, + rguess, + rguess, + wguess, + np.ones(p.M), + 0.6376591201150815, + BQguess, + 0.05738932081035772, + None, + None, + 139355.1547340256, + p, + dask_client, + False, + ) + + Y = ss["Y"] + assert np.isclose(ss["D_ODA"], 0.3 * Y) + assert np.isclose( + ss["new_borrowing_ODA"], + 0.3 * Y * ((1 + p.g_n_ss) * np.exp(p.g_y) - 1), + ) + assert np.isclose(ss["debt_service_ODA"], p.r_ODA[-1] * 0.3 * Y) + assert np.isclose( + ss["G"], + ss["total_tax_revenue"] + + ss["new_borrowing"] + + ss["foreign_aid"] + + ss["new_borrowing_ODA"] + - ss["debt_service_ODA"] + - ss["agg_pension_outlays"] + - ss["TR"] + - ss["debt_service"] + - ss["UBI"] + - ss["I_g"], + ) + assert np.abs(ss["resource_constraint_error"]).max() < 1e-6 + + param_updates5 = {"zeta_K": [1.0], "budget_balance": True, "alpha_G": [0.0]} filename5 = "SS_solver_outputs_baseline_small_open_budget_balance.pkl" param_updates6 = { diff --git a/tests/test_fiscal.py b/tests/test_fiscal.py index 04f3c92b1..7deb7edb6 100644 --- a/tests/test_fiscal.py +++ b/tests/test_fiscal.py @@ -477,3 +477,148 @@ def test_get_K_g(K_g0, I_g, method, leakage, expected): test_val = fiscal.get_K_g(K_g0, I_g, p, method) assert np.allclose(test_val, expected) + + +@pytest.mark.parametrize( + "method", + ["SS", "TPI"], + ids=["SS", "TPI"], +) +def test_get_ODA(method): + """ + Test of the stock, new borrowing, and interest on concessional (ODA) + government debt. + """ + p = Specifications() + p.T = 2 + p.g_y = 0.03 + p.g_n_ss = 0.02 + p.g_n = np.array([0.02, 0.01]) + p.alpha_ODA = np.array([0.1, 0.5, 0.5]) + p.r_ODA = np.array([0.01, -0.01, -0.01]) + Y = np.array([0.2, 4.0]) + if method == "SS": + D_ODA, new_borrowing_ODA, debt_service_ODA = fiscal.get_ODA( + Y[-1], p, method + ) + expected = ( + 2.0, + 2.0 * (1.02 * np.exp(0.03) - 1), + -0.01 * 2.0, + ) + else: + D_ODA, new_borrowing_ODA, debt_service_ODA = fiscal.get_ODA( + Y, p, method + ) + # the stock in period T uses output in period T - 1 + expected = ( + np.array([0.02, 2.0]), + np.array( + [ + 2.0 * np.exp(0.03) * 1.02 - 0.02, + 2.0 * np.exp(0.03) * 1.01 - 2.0, + ] + ), + np.array([0.01 * 0.02, -0.01 * 2.0]), + ) + for test_val, expected_val in zip( + (D_ODA, new_borrowing_ODA, debt_service_ODA), expected + ): + assert np.allclose(test_val, expected_val) + + +def test_get_ODA_zero_by_default(): + """ + With the default parameters there is no concessional debt. + """ + p = Specifications() + Y = np.ones(p.T) * 2.0 + for method, y in (("SS", 2.0), ("TPI", Y)): + for v in fiscal.get_ODA(y, p, method): + assert np.allclose(v, 0.0) + + +def test_get_G_ss_ODA(): + """ + Concessional debt adds its new borrowing, less its interest, to the + resources that finance steady-state government spending. + """ + Y = 2.2 + new_borrowing = 0.072076633 + debt_service = 0.042345192 + p = Specifications() + p.update_specifications({"alpha_ODA": [0.3], "r_ODA_annual": [0.01]}) + test_G = fiscal.get_G_ss( + Y, 2.3, 0.0, 1.6, 0.0, 0.0, 0.0, new_borrowing, debt_service, p + ) + D_ODA = 0.3 * Y + expected_G = ( + expected_G1 + + D_ODA * ((1 + p.g_n_ss) * np.exp(p.g_y) - 1) + - p.r_ODA[-1] * D_ODA + ) + + assert np.allclose(test_G, expected_G) + + +def test_D_G_path_ODA_budget_constraint(): + """ + With concessional debt, the time path of market debt and spending + satisfies the government budget constraint each period: + growth * D_{t+1} + new ODA borrowing_t + Rev_t + FA_t = + (1 + r_gov_t) D_t + ODA interest_t + G_t + I_g_t + TR_t + UBI_t + + pensions_t. + """ + p = Specifications() + p.update_specifications( + { + "T": 320, + "S": 80, + "debt_ratio_ss": 1.2, + "tG1": 20, + "tG2": 256, + "alpha_T": [0.09], + "alpha_G": [0.05], + "rho_G": 0.1, + "g_y_annual": 0.03, + "alpha_FA": [0.01], + "alpha_ODA": [0.2, 0.25, 0.3], + "r_ODA_annual": [-0.01], + }, + raise_errors=False, + ) + r = np.ones(p.T + p.S) * 0.05 + p.g_n = np.ones(p.T + p.S) * 0.02 + Y_path = Y.copy() + TR_path = TR.copy() + zeros = np.zeros_like(TR_path) + foreign_aid = p.alpha_FA[: p.T] * Y_path[: p.T] + dg_fixed_values = ( + Y_path, + Revenue, + zeros, + zeros, + TR_path, + zeros, + foreign_aid, + Gbaseline, + 0.59, + ) + D, G, _, _, r_gov, _, _, _ = fiscal.D_G_path(r, dg_fixed_values, p) + _, new_borrowing_ODA, debt_service_ODA = fiscal.get_ODA(Y_path, p, "TPI") + growth = np.exp(p.g_y) * (1 + p.g_n[: p.T - 1]) + lhs = ( + growth * D[1 : p.T] + + new_borrowing_ODA[: p.T - 1] + + Revenue[: p.T - 1] + + foreign_aid[: p.T - 1] + ) + rhs = ( + (1 + r_gov[: p.T - 1]) * D[: p.T - 1] + + debt_service_ODA[: p.T - 1] + + G[: p.T - 1] + + TR_path[: p.T - 1] + ) + assert np.allclose(lhs, rhs) + # the closure rule still brings market debt to its target + assert np.isclose(D[p.T - 1] / Y_path[p.T - 2], p.debt_ratio_ss) diff --git a/tests/test_parameters.py b/tests/test_parameters.py index 458ea2661..0c4a5dd38 100644 --- a/tests/test_parameters.py +++ b/tests/test_parameters.py @@ -83,6 +83,27 @@ def test_alpha_FA_extended_over_time_path(): assert specs.alpha_FA[-1] == 0.03 +def test_ODA_parameters_extended_and_converted(): + # Concessional (ODA) debt and its interest rate may vary over the time + # path; the annual rate is converted to a model-period rate. + specs = Specifications() + assert np.all(specs.alpha_ODA == 0.0) + assert np.all(specs.r_ODA == 0.0) + specs.update_specifications( + { + "alpha_ODA": [0.1, 0.2], + "r_ODA_annual": [0.01, -0.02], + } + ) + assert specs.alpha_ODA.shape[0] == specs.T + specs.S + assert specs.alpha_ODA[0] == 0.1 + assert specs.alpha_ODA[-1] == 0.2 + assert specs.r_ODA.shape[0] == specs.T + specs.S + years_per_period = (specs.ending_age - specs.starting_age) / specs.S + assert np.isclose(specs.r_ODA[0], 1.01**years_per_period - 1) + assert np.isclose(specs.r_ODA[-1], 0.98**years_per_period - 1) + + def test_tau_payroll_extended_over_T_and_J(): # tau_payroll may vary over the time path and across lifetime income # groups, so it should be extrapolated to T+S x J from a scalar, a diff --git a/uv.lock b/uv.lock index 07bf09247..e080afacc 100644 --- a/uv.lock +++ b/uv.lock @@ -2027,7 +2027,7 @@ wheels = [ [[package]] name = "ogcore" -version = "0.24.4" +version = "0.25.0" source = { editable = "." } dependencies = [ { name = "dask" }, From caedee62646acdea7474c263c1a4d49de0a8ec7e Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Thu, 12 Nov 2026 12:49:53 -0500 Subject: [PATCH 2/6] Concessional debt outputs in unstationarize_vars; document it under baseline_spending --- CHANGELOG.md | 2 +- docs/book/content/theory/government.md | 2 ++ ogcore/utils.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f3da474c..314ccd4ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Adds - Adds concessional government debt owed to official foreign lenders (official development assistance loans), addressing Issue #1125. The new time-varying parameter `alpha_ODA` (default 0.0) sets the stock of this debt as a share of GDP, and `r_ODA_annual` (default 0.0, time varying, converted to a model-period rate `r_ODA`) its real interest rate. Each period the government receives the new concessional borrowing and pays its interest, in the budget constraint of the steady state and the time path (`fiscal.D_G_path`, `fiscal.get_G_ss`, and the balanced-budget case of `fiscal.get_TR`), and the interest is paid abroad at `r_ODA` in the resource constraint, alongside the foreign-held market debt. Concessional debt is separate from the market debt `D`: it is not held by households, so it does not enter the portfolio return `r_p`, and `r_gov`, `debt_ratio_ss` and the closure rule, and `zeta_D` refer to market debt. - Adds `fiscal.get_ODA`, which returns the stock of concessional debt, new concessional borrowing, and its interest in the steady state or along the time path. -- Adds `D_ODA`, `new_borrowing_ODA`, and `debt_service_ODA` to the steady-state and time-path output, and includes concessional interest in `total_government_outlays`. +- Adds `D_ODA`, `new_borrowing_ODA`, and `debt_service_ODA` to the steady-state and time-path output (and to `utils.unstationarize_vars`), and includes concessional interest in `total_government_outlays`. Concessional debt is a share of GDP in the reform as well, including when `baseline_spending=True`. - Adds concessional debt to the government budget constraint, the budget closure rules, and their stationarized forms in the documentation, and adds concessional debt and foreign aid to the goods market clearing condition. - Adds tests of `fiscal.get_ODA`, of the steady-state spending and the time path of debt and spending with concessional debt (the budget constraint holds each period), of the new parameters, and a steady-state solution with concessional debt that balances the budget and clears the goods market. diff --git a/docs/book/content/theory/government.md b/docs/book/content/theory/government.md index da6250ea7..8f946621f 100644 --- a/docs/book/content/theory/government.md +++ b/docs/book/content/theory/government.md @@ -648,6 +648,8 @@ Foreign aid to the domestic government, $FA_t$, is treated the same way. In the This means that changes to `alpha_FA` in the reform have no effect when `baseline_spending=True`; use `alpha_bs_FA` to change the level of foreign aid relative to the baseline instead. +Concessional debt $D^{ODA}_t$ is not affected by `baseline_spending`: in the reform simulation it is always the fraction $\alpha_{ODA,t}$ of GDP in the reform. + Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRule`}) still takes effect in the case of `baseline_spending=True`. What this means is that the relation described above holds until the period in which the closure rules takes effect. Once the closure rule begins, the path of $G$ (and/or $TR$, depending on the closure rule used) will adjust as determined by the rule to close the government budget in the long run. (SecUnbalGBCrev)= diff --git a/ogcore/utils.py b/ogcore/utils.py index 91acb38de..d0677ac55 100644 --- a/ogcore/utils.py +++ b/ogcore/utils.py @@ -1357,6 +1357,9 @@ def unstationarize_vars( "UBI_path", "new_borrowing_f", "debt_service_f", + "D_ODA", + "new_borrowing_ODA", + "debt_service_ODA", ]: non_stationary_output = tpi_vars[var][:T] * pop_growth * prod_growth elif var in [ From 126ed1e4c21ac155714206e13f6666131f3d3c85 Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Fri, 13 Nov 2026 09:56:09 -0500 Subject: [PATCH 3/6] Test a transition with concessional debt that falls over time: stock and flows, the budget in every period, and the resource constraint along the path --- tests/test_TPI.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/test_TPI.py b/tests/test_TPI.py index 74c2bb5c0..ed8fb2272 100644 --- a/tests/test_TPI.py +++ b/tests/test_TPI.py @@ -1311,6 +1311,66 @@ def test_run_TPI_extra(baseline, param_updates, filename, tmpdir, dask_client): ) +@pytest.mark.local +def test_run_TPI_ODA(tmpdir, dask_client): + """ + A baseline transition with concessional (ODA) debt that falls over + time and gets dearer: the stock, its new borrowing and its interest + follow alpha_ODA and r_ODA period by period, the government budget + holds in every period with the ODA flows in it, and the goods market + clears along the path with ODA interest paid abroad. + """ + baseline_dir = os.path.join(tmpdir, "baseline") + p = Specifications( + baseline=True, + baseline_dir=baseline_dir, + output_base=baseline_dir, + num_workers=NUM_WORKERS, + ) + p.update_specifications( + { + "alpha_ODA": [0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0.0], + "r_ODA_annual": [-0.01, 0.0, 0.01, 0.02], + } + ) + SS.ENFORCE_SOLUTION_CHECKS = True + ss_outputs = SS.run_SS(p, client=dask_client) + utils.mkdirs(os.path.join(p.baseline_dir, "SS")) + with open(os.path.join(p.baseline_dir, "SS", "SS_vars.pkl"), "wb") as f: + pickle.dump(ss_outputs, f) + tpi = TPI.run_TPI(p, client=dask_client) + + T = p.T + Y = tpi["Y"][:T] + growth = np.exp(p.g_y) * (1 + p.g_n[:T]) + # the stock and its flows + assert np.allclose(tpi["D_ODA"], p.alpha_ODA[:T] * Y) + D_ODA_next = p.alpha_ODA[1 : T + 1] * np.append(Y[1:], Y[-1]) + assert np.allclose( + tpi["new_borrowing_ODA"], D_ODA_next * growth - tpi["D_ODA"] + ) + assert np.allclose(tpi["debt_service_ODA"], p.r_ODA[:T] * tpi["D_ODA"]) + assert tpi["D_ODA"][10] == 0.0 + # the government budget, period by period + D = tpi["D"] + ODA_net = tpi["new_borrowing_ODA"] - tpi["debt_service_ODA"] + outlays = ( + (1 + tpi["r_gov"][: T - 1]) * D[: T - 1] + + tpi["G"][: T - 1] + + tpi["I_g"][: T - 1] + + tpi["TR"][: T - 1] + + tpi["UBI"][: T - 1] + + tpi["agg_pension_outlays"][: T - 1] + - tpi["total_tax_revenue"][: T - 1] + - tpi["foreign_aid"][: T - 1] + - ODA_net[: T - 1] + ) + assert np.allclose(D[1:T] * growth[: T - 1], outlays, atol=1e-8) + # the goods market along the path + rc = np.abs(np.asarray(tpi["resource_constraint_error"])[: T - 1]) + assert rc.max() < p.RC_TPI + + class _ReachedTPILoop(Exception): """Sentinel raised in place of the household inner loop.""" From 08965b62de1183164f9dcde115f63f3632bae4ab Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Fri, 13 Nov 2026 12:52:16 -0500 Subject: [PATCH 4/6] Generalize to government debt contracted abroad (alpha_D_ext, r_D_ext_annual), price the debt premium on all government debt, report total debt, and document the new outputs --- CHANGELOG.md | 16 +-- docs/book/content/api/fiscal.rst | 2 +- docs/book/content/intro/parameters.md | 8 +- docs/book/content/theory/government.md | 30 +++--- docs/book/content/theory/market_clearing.md | 6 +- docs/book/content/theory/stationarization.md | 16 +-- ogcore/SS.py | 36 ++++--- ogcore/TPI.py | 27 +++-- ogcore/default_parameters.json | 20 ++-- ogcore/fiscal.py | 105 +++++++++++-------- ogcore/model_variables.json | 29 ++++- ogcore/output_plots.py | 8 +- ogcore/output_tables.py | 13 ++- ogcore/parameters.py | 10 +- ogcore/utils.py | 6 +- tests/test_SS.py | 28 +++-- tests/test_TPI.py | 30 +++--- tests/test_fiscal.py | 104 +++++++++++++----- tests/test_parameters.py | 24 ++--- 19 files changed, 321 insertions(+), 197 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 314ccd4ec..6f6d5c6d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,14 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.25.0] - 2026-11-12 +## [0.25.0] - 2026-11-13 ### Adds -- Adds concessional government debt owed to official foreign lenders (official development assistance loans), addressing Issue #1125. The new time-varying parameter `alpha_ODA` (default 0.0) sets the stock of this debt as a share of GDP, and `r_ODA_annual` (default 0.0, time varying, converted to a model-period rate `r_ODA`) its real interest rate. Each period the government receives the new concessional borrowing and pays its interest, in the budget constraint of the steady state and the time path (`fiscal.D_G_path`, `fiscal.get_G_ss`, and the balanced-budget case of `fiscal.get_TR`), and the interest is paid abroad at `r_ODA` in the resource constraint, alongside the foreign-held market debt. Concessional debt is separate from the market debt `D`: it is not held by households, so it does not enter the portfolio return `r_p`, and `r_gov`, `debt_ratio_ss` and the closure rule, and `zeta_D` refer to market debt. -- Adds `fiscal.get_ODA`, which returns the stock of concessional debt, new concessional borrowing, and its interest in the steady state or along the time path. -- Adds `D_ODA`, `new_borrowing_ODA`, and `debt_service_ODA` to the steady-state and time-path output (and to `utils.unstationarize_vars`), and includes concessional interest in `total_government_outlays`. Concessional debt is a share of GDP in the reform as well, including when `baseline_spending=True`. -- Adds concessional debt to the government budget constraint, the budget closure rules, and their stationarized forms in the documentation, and adds concessional debt and foreign aid to the goods market clearing condition. -- Adds tests of `fiscal.get_ODA`, of the steady-state spending and the time path of debt and spending with concessional debt (the budget constraint holds each period), of the new parameters, and a steady-state solution with concessional debt that balances the budget and clears the goods market. +- Adds government debt contracted abroad at its own interest rate, addressing Issue #1125 (concessional debt from official lenders), and usable for any government debt contracted abroad, concessional or commercial. The new time-varying parameter `alpha_D_ext` (default 0.0) sets this debt as a share of GDP, and `r_D_ext_annual` (default 0.0, time varying, converted to a model-period rate `r_D_ext`) its real interest rate. Each period the government receives the new external borrowing and pays its interest, in the budget constraint of the steady state and the time path (`fiscal.D_G_path`, `fiscal.get_G_ss`, and the balanced-budget case of `fiscal.get_TR`), and the interest is paid abroad at `r_D_ext` in the resource constraint. The debt is held only by foreigners and is separate from the market debt `D`: it does not enter households' portfolio return `r_p`, and `debt_ratio_ss`, the closure rule and `zeta_D` refer to market debt. +- Adds `fiscal.get_D_ext`, which returns the stock of debt contracted abroad, new external borrowing, and its interest in the steady state or along the time path. +- Adds `D_ext`, `new_borrowing_ext`, and `debt_service_ext` to the steady-state and time-path output (with their descriptions in `model_variables.json`, and in `utils.unstationarize_vars`), and includes external interest in `total_government_outlays`. The debt is a share of GDP in the reform as well, including when `baseline_spending=True`. +- Adds the debt contracted abroad to the government budget constraint, the budget closure rules, and their stationarized forms in the documentation, and adds it and foreign aid to the goods market clearing condition. +- Adds tests of `fiscal.get_D_ext`, of the steady-state spending and the time path of debt and spending with debt contracted abroad (the budget constraint holds each period), of the premium on total debt, of the new parameters, a steady-state solution that balances the budget and clears the goods market, and a time path (marked `local`) with a falling external debt that keeps the budget and the goods market in balance in every period. + +### Updates +- The debt-elastic premium on `r_gov` (`r_gov_DY`, `r_gov_DY2`) is evaluated at all government debt, market debt plus debt contracted abroad. With `alpha_D_ext` at its default of zero this is the market-debt ratio, so results are unchanged. +- The debt-to-GDP ratio in `output_tables.macro_table_SS` and in the calibration moments counts debt contracted abroad, and `output_plots.plot_all` adds it to the debt-to-GDP plot when it is not zero. Both are unchanged when `alpha_D_ext` is zero. ## [0.24.4] - 2026-11-07 diff --git a/docs/book/content/api/fiscal.rst b/docs/book/content/api/fiscal.rst index c0a9ad2be..41d4a398e 100644 --- a/docs/book/content/api/fiscal.rst +++ b/docs/book/content/api/fiscal.rst @@ -10,4 +10,4 @@ ogcore.fiscal .. automodule:: ogcore.fiscal :members: D_G_path, get_D_ss, get_G_ss, get_debt_service_f, get_TR, - get_r_gov, get_I_g, get_foreign_aid, get_ODA, get_K_g + get_r_gov, get_I_g, get_foreign_aid, get_D_ext, get_K_g diff --git a/docs/book/content/intro/parameters.md b/docs/book/content/intro/parameters.md index b930dc8f5..dec9be51c 100644 --- a/docs/book/content/intro/parameters.md +++ b/docs/book/content/intro/parameters.md @@ -304,15 +304,15 @@ _Valid Range:_ min = 0.0 and max = 1.0 _Out-of-Range Action:_ error -#### `alpha_ODA` -_Description:_ Stock of government debt owed to official foreign lenders on concessional terms (e.g., official development assistance loans from multilateral and bilateral lenders), as a share of GDP. This debt is held entirely by foreigners, pays the interest rate r_ODA_annual, and is separate from the market debt D whose path the budget closure rule targets. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered. +#### `alpha_D_ext` +_Description:_ Stock of government debt contracted abroad at its own interest rate, as a share of GDP: for example concessional loans from multilateral and bilateral lenders (official development assistance), or bonds and loans on commercial terms. This debt is held only by foreigners and is not part of the market debt D: it does not enter households' portfolio return, pays r_D_ext_annual, and is paid abroad at that rate. The debt-elastic premium on r_gov is evaluated at all government debt, D plus this debt, while the budget closure rule (debt_ratio_ss) and zeta_D refer to market debt. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered. _Value Type:_ float _Valid Range:_ min = 0.0 and max = 3.0 _Out-of-Range Action:_ error -#### `r_ODA_annual` -_Description:_ Annual real interest rate paid on government debt owed to official foreign lenders on concessional terms (alpha_ODA). Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered. +#### `r_D_ext_annual` +_Description:_ Annual real interest rate paid on government debt contracted abroad (alpha_D_ext), in units of the model's output: for debt in foreign currency, the foreign-currency rate less foreign inflation, plus any expected real depreciation. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered. _Value Type:_ float _Valid Range:_ min = -0.2 and max = 0.2 _Out-of-Range Action:_ error diff --git a/docs/book/content/theory/government.md b/docs/book/content/theory/government.md index 8f946621f..af6eac805 100644 --- a/docs/book/content/theory/government.md +++ b/docs/book/content/theory/government.md @@ -648,7 +648,7 @@ Foreign aid to the domestic government, $FA_t$, is treated the same way. In the This means that changes to `alpha_FA` in the reform have no effect when `baseline_spending=True`; use `alpha_bs_FA` to change the level of foreign aid relative to the baseline instead. -Concessional debt $D^{ODA}_t$ is not affected by `baseline_spending`: in the reform simulation it is always the fraction $\alpha_{ODA,t}$ of GDP in the reform. +Debt contracted abroad $D^{ext}_t$ is not affected by `baseline_spending`: in the reform simulation it is always the fraction $\alpha_{D,ext,t}$ of GDP in the reform. Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRule`}) still takes effect in the case of `baseline_spending=True`. What this means is that the relation described above holds until the period in which the closure rules takes effect. Once the closure rule begins, the path of $G$ (and/or $TR$, depending on the closure rule used) will adjust as determined by the rule to close the government budget in the long run. @@ -697,11 +697,11 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul (SecUnbalGBCbudgConstr)= ## Government Budget Constraint - Let the level of government debt in period $t$ be given by $D_t$. The government may also owe concessional debt $D^{ODA}_t$ to official foreign lenders, described below. The government budget constraint requires that government revenue $Rev_t$, external foreign assistance, $FA_t$, plus the budget deficit financed by new borrowing ($D_{t+1} - D_t$ and $D^{ODA}_{t+1} - D^{ODA}_t$) equal expenditures on interest on the debt, government spending on public goods $G_t$, total infrastructure investments $I_{g,t}$, total pension outlays, total transfer payments to households $TR_t$, and $UBI_t$ every period $t$, + Let the level of government debt in period $t$ be given by $D_t$. The government may also owe debt contracted abroad at its own interest rate, $D^{ext}_t$, described below. The government budget constraint requires that government revenue $Rev_t$, external foreign assistance, $FA_t$, plus the budget deficit financed by new borrowing ($D_{t+1} - D_t$ and $D^{ext}_{t+1} - D^{ext}_t$) equal expenditures on interest on the debt, government spending on public goods $G_t$, total infrastructure investments $I_{g,t}$, total pension outlays, total transfer payments to households $TR_t$, and $UBI_t$ every period $t$, ```{math} :label: EqUnbalGBCbudgConstr - D_{t+1} + D^{ODA}_{t+1} + Rev_t + FA_t = (1 + r_{gov,t})D_t + (1 + r_{ODA,t})D^{ODA}_t + G_t + I_{g,t} + Pensions_t + TR_t + UBI_t \quad\forall t + D_{t+1} + D^{ext}_{t+1} + Rev_t + FA_t = (1 + r_{gov,t})D_t + (1 + r_{ext,t})D^{ext}_t + G_t + I_{g,t} + Pensions_t + TR_t + UBI_t \quad\forall t ``` where $r_{gov,t}$ is the interest rate paid by the government defined in equation {eq}`EqUnbalGBC_rate_wedge` below, $G_{t}$ is government spending on public goods, $I_{g,t}$ is total government spending on infrastructure investment, $TR_{t}$ are non-pension government transfers, and $UBI_t$ is the total UBI transfer outlays across households in time $t$. All variables in {eq}`EqUnbalGBCbudgConstr` are real variables denominated in units of current-period output in industry $M$ the numeraire ($p_{M,t}=1$ for all $t$). @@ -738,14 +738,14 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul where $\delta_g$ is the depreciation rate on infrastructure and $\phi_g$ (`infra_investment_leakage_rate`) is the fraction of infrastructure investment lost to leakage (e.g., corruption or other frictions). The stock of public capital in each industry $m$ complements labor and private capital in the production function of the representative firm, in Equation {eq}`EqFirmsCESprodfun`. - Many low-income countries borrow from official lenders, such as multilateral development banks and bilateral donors, on concessional terms: at interest rates well below market rates, in amounts the lenders decide. `OG-Core` models this concessional debt (official development assistance loans) as a stock $D^{ODA}_t$ held entirely by foreigners, set as a time-dependent fraction $\alpha_{ODA,t}$ (`alpha_ODA`) of GDP and paying the exogenous real interest rate $r_{ODA,t}$ (`r_ODA_annual`, converted to a model-period rate). + Governments also borrow abroad directly, outside the domestic bond market: from official lenders such as multilateral development banks and bilateral donors, often on concessional terms (at interest rates well below market rates, in amounts the lenders decide), and on commercial terms through bonds and loans issued abroad. `OG-Core` models this debt contracted abroad as a stock $D^{ext}_t$ held entirely by foreigners, set as a time-dependent fraction $\alpha_{D,ext,t}$ (`alpha_D_ext`) of GDP and paying the exogenous real interest rate $r_{ext,t}$ (`r_D_ext_annual`, converted to a model-period rate). The model has no exchange rate, so for debt in foreign currency $r_{ext,t}$ is the foreign-currency rate less foreign inflation, plus any expected real depreciation. ```{math} - :label: EqUnbalGBC_ODA - D^{ODA}_t = \alpha_{ODA,t}\: Y_t \quad\forall t + :label: EqUnbalGBC_D_ext + D^{ext}_t = \alpha_{D,ext,t}\: Y_t \quad\forall t ``` - The government receives the new concessional borrowing $D^{ODA}_{t+1} - D^{ODA}_t$ and pays the interest $r_{ODA,t}D^{ODA}_t$ each period. Concessional debt is separate from the market debt $D_t$: it is not part of household savings, so it does not enter the household portfolio return $r_{p,t}$ in {eq}`eq_portfolio_return`, and the interest rate $r_{gov,t}$, the debt-to-GDP target $\alpha_D$ of the budget closure rule, and the share of new debt bought by foreigners $\zeta_D$ all refer to market debt. Its interest is paid abroad at $r_{ODA,t}$ in the goods market clearing condition (Chapter {ref}`Chap_MarkClr`). By default $\alpha_{ODA,t} = 0$. + The government receives the new external borrowing $D^{ext}_{t+1} - D^{ext}_t$ and pays the interest $r_{ext,t}D^{ext}_t$ each period. Debt contracted abroad is separate from the market debt $D_t$: it is not part of household savings, so it does not enter the household portfolio return $r_{p,t}$ in {eq}`eq_portfolio_return`, and the debt-to-GDP target $\alpha_D$ of the budget closure rule and the share of new market debt bought by foreigners $\zeta_D$ refer to market debt; $D^f_t$ is then the part of market debt held by foreigners. The debt-elastic premium on $r_{gov,t}$ in {eq}`EqUnbalGBC_rate_wedge` is evaluated at all government debt, $D_t + D^{ext}_t$. Its interest is paid abroad at $r_{ext,t}$ in the goods market clearing condition (Chapter {ref}`Chap_MarkClr`). Because the stock is set by $\alpha_{D,ext,t}$, a reform that changes borrowing changes market debt only, unless it also changes $\alpha_{D,ext,t}$; and in the steady state all government debt is $\alpha_D + \alpha_{D,ext}$ of GDP. By default $\alpha_{D,ext,t} = 0$. Aggregate spending on UBI at time $t$ is the sum of UBI payments across all households at time $t$: @@ -762,10 +762,10 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul ```{math} :label: EqUnbalGBC_rate_wedge - 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 + r_{gov, t} = (1 - \tau_{d, t})r_{t} - \mu_{d} + \beta_{1}\frac{D_t + D^{ext}_t}{Y_t} + \beta_{2}\left(\frac{D_t + D^{ext}_t}{Y_t}\right)^2 ``` - where $r_t$ is the marginal product of capital faced by firms. The two parameters, $\tau_{d,t}$ and $\mu_{d,t}$ can be used to allow for a government interest rate that is a percentage hair cut from the market rate or a government interest rate with a constant risk premium. The parameters $\beta_1$ and $\beta_2$ can be used to allow for a quadratic risk premium on government debt that is a function of the debt-to-GDP ratio. + where $r_t$ is the marginal product of capital faced by firms. The two parameters, $\tau_{d,t}$ and $\mu_{d,t}$ can be used to allow for a government interest rate that is a percentage hair cut from the market rate or a government interest rate with a constant risk premium. The parameters $\beta_1$ and $\beta_2$ can be used to allow for a quadratic risk premium on government debt that is a function of the debt-to-GDP ratio. The ratio counts all government debt, the market debt $D_t$ and the debt contracted abroad $D^{ext}_t$, since the risk of the government's debt depends on everything it owes; with no debt contracted abroad it is $D_t/Y_t$. (SecUnbalGBCcloseRule)= @@ -804,8 +804,8 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul &\text{where}\quad g_{g,t} = \begin{cases} 1 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\:\text{if}\quad t < T_{G1} \\ - \frac{\left[\rho_{d}\alpha_{D}Y_{t} + (1-\rho_{d})D_{t}\right] - (1+r_{gov,t})D_{t} - I_{g,t} - TR_{t} - UBI_{t} + Rev_{t} + FA_{t} + D^{ODA}_{t+1} - (1+r_{ODA,t})D^{ODA}_{t}}{\alpha_g Y_t} \quad\text{if}\quad T_{G1}\leq t= p.tG1) and (t < p.tG2): G[t] = ( growth[t + 1] @@ -140,7 +148,7 @@ def D_G_path(r, dg_fixed_values, p): - (1 + r_gov[t]) * D[t] + total_tax_revenue[t] + foreign_aid[t] - + ODA_net[t] + + ext_net[t] - agg_pension_outlays[t] - I_g[t - 1] - TR[t] @@ -152,7 +160,7 @@ def D_G_path(r, dg_fixed_values, p): - (1 + r_gov[t]) * D[t] + total_tax_revenue[t] + foreign_aid[t] - + ODA_net[t] + + ext_net[t] - agg_pension_outlays[t] - I_g[t - 1] - TR[t] @@ -172,15 +180,17 @@ def D_G_path(r, dg_fixed_values, p): + agg_pension_outlays[t - 1] - total_tax_revenue[t - 1] - foreign_aid[t - 1] - - ODA_net[t - 1] + - ext_net[t - 1] + ) + r_gov[t] = get_r_gov( + r[t], D[t] / Y[t] + ext_ratio[t], p, method="scalar", t=t ) - r_gov[t] = get_r_gov(r[t], D[t] / Y[t], p, method="scalar", t=t) G[t] = ( growth[t] * (p.debt_ratio_ss * Y[t]) - (1 + r_gov[t]) * D[t] + total_tax_revenue[t] + foreign_aid[t] - + ODA_net[t] + + ext_net[t] - agg_pension_outlays[t] - I_g[t - 1] - TR[t] @@ -195,7 +205,7 @@ def D_G_path(r, dg_fixed_values, p): + agg_pension_outlays[t] - total_tax_revenue[t] - foreign_aid[t] - - ODA_net[t] + - ext_net[t] ) D_ratio_max = np.amax(D[: p.T] / Y[: p.T]) print("Maximum debt ratio: ", D_ratio_max) @@ -292,8 +302,8 @@ def get_G_ss( .. math:: \bar{G} = \bar{Rev} + \overline{FA} + \bar{D}\bigl[(1 + \bar{g}_n)e^{g_y} - (1 + \bar{r}_{gov})\bigr] - + \bar{D}^{ODA}\bigl[(1 + \bar{g}_n)e^{g_y} - - (1 + \bar{r}_{ODA})\bigr] + + \bar{D}^{ext}\bigl[(1 + \bar{g}_n)e^{g_y} + - (1 + \bar{r}_{ext})\bigr] - \bar{I}_g - \bar{TR} - \overline{UBI} Args: @@ -316,13 +326,13 @@ def get_G_ss( if p.budget_balance: G = p.alpha_G[-1] * Y else: - _, new_borrowing_ODA, debt_service_ODA = get_ODA(Y, p, "SS") + _, new_borrowing_ext, debt_service_ext = get_D_ext(Y, p, "SS") G = ( total_tax_revenue + new_borrowing + foreign_aid - + new_borrowing_ODA - - debt_service_ODA + + new_borrowing_ext + - debt_service_ext - (agg_pension_outlays + TR + debt_service + UBI_outlays + I_g) ) @@ -391,12 +401,12 @@ def get_TR( """ if p.budget_balance: - _, new_borrowing_ODA, debt_service_ODA = get_ODA(Y, p, method) + _, new_borrowing_ext, debt_service_ext = get_D_ext(Y, p, method) new_TR = ( total_tax_revenue + foreign_aid - + new_borrowing_ODA - - debt_service_ODA + + new_borrowing_ext + - debt_service_ext - agg_pension_outlays - G - UBI_outlays @@ -527,18 +537,21 @@ def get_foreign_aid(Y, FA_baseline, p, method="SS"): return foreign_aid -def get_ODA(Y, p, method="SS"): +def get_D_ext(Y, p, method="SS"): r""" - Find the stock of concessional government debt held by official - foreign lenders, the new concessional borrowing, and its interest. + Find the stock of government debt contracted abroad at its own + interest rate (for example concessional loans from official lenders, + or bonds and loans on commercial terms), the new external borrowing, + and its interest. This debt is held only by foreigners and is not part + of the market debt D or of households' portfolio. .. math:: \begin{split} - \hat{D}^{ODA}_{t} &= \alpha_{ODA,t}\hat{Y}_{t} \\ - \text{new ODA borrowing}_t &= e^{g_y}\left(1 + - \tilde{g}_{n,t+1}\right)\hat{D}^{ODA}_{t+1} - - \hat{D}^{ODA}_{t} \\ - \text{ODA debt service}_t &= r_{ODA,t}\hat{D}^{ODA}_{t} + \hat{D}^{ext}_{t} &= \alpha_{D,ext,t}\hat{Y}_{t} \\ + \text{new external borrowing}_t &= e^{g_y}\left(1 + + \tilde{g}_{n,t+1}\right)\hat{D}^{ext}_{t+1} - + \hat{D}^{ext}_{t} \\ + \text{external debt service}_t &= r_{ext,t}\hat{D}^{ext}_{t} \end{split} Args: @@ -548,29 +561,29 @@ def get_ODA(Y, p, method="SS"): path Returns: - (tuple): concessional debt variables: + (tuple): external debt variables: - * D_ODA (array_like): stock of concessional debt - * new_borrowing_ODA (array_like): new concessional borrowing - * debt_service_ODA (array_like): interest on concessional debt + * D_ext (array_like): stock of debt contracted abroad + * new_borrowing_ext (array_like): new external borrowing + * debt_service_ext (array_like): interest on external debt """ if method == "SS": - D_ODA = p.alpha_ODA[-1] * Y - new_borrowing_ODA = D_ODA * ((1 + p.g_n_ss) * np.exp(p.g_y) - 1) - debt_service_ODA = p.r_ODA[-1] * D_ODA + D_ext = p.alpha_D_ext[-1] * Y + new_borrowing_ext = D_ext * ((1 + p.g_n_ss) * np.exp(p.g_y) - 1) + debt_service_ext = p.r_D_ext[-1] * D_ext else: # The stock in period T needs output in period T, beyond the # path; output is at its steady state by then, so carry the # last value forward. Y_path = np.append(Y[: p.T], Y[p.T - 1]) - D_ODA = p.alpha_ODA[: p.T + 1] * Y_path - new_borrowing_ODA = ( - D_ODA[1:] * np.exp(p.g_y) * (1 + p.g_n[: p.T]) - D_ODA[:-1] + D_ext = p.alpha_D_ext[: p.T + 1] * Y_path + new_borrowing_ext = ( + D_ext[1:] * np.exp(p.g_y) * (1 + p.g_n[: p.T]) - D_ext[:-1] ) - D_ODA = D_ODA[:-1] - debt_service_ODA = p.r_ODA[: p.T] * D_ODA + D_ext = D_ext[:-1] + debt_service_ext = p.r_D_ext[: p.T] * D_ext - return D_ODA, new_borrowing_ODA, debt_service_ODA + return D_ext, new_borrowing_ext, debt_service_ext def get_K_g(K_g0, I_g, p, method): diff --git a/ogcore/model_variables.json b/ogcore/model_variables.json index a6745d377..95b5e0cb8 100644 --- a/ogcore/model_variables.json +++ b/ogcore/model_variables.json @@ -270,7 +270,7 @@ "toGDP_label": "Consumption Tax Revenue-to-GDP" }, "D": { - "desc": "Total government debt", + "desc": "Government debt issued in the domestic market (market debt), excluding debt contracted abroad (D_ext)", "section": "Government Revenues, Outlays, and Debt", "type": "array-like", "TPI dimensions": "T", @@ -296,6 +296,33 @@ "label": "Domestically-owned Gov Debt ($D^d_t$)", "toGDP_label": "Domestically-owned Debt-to-GDP ($D^d_{t}/Y_t$)" }, + "D_ext": { + "desc": "Government debt contracted abroad at its own interest rate (alpha_D_ext times GDP), held entirely by foreigners and outside the household portfolio", + "section": "Government Revenues, Outlays, and Debt", + "type": "array-like", + "TPI dimensions": "T", + "SS dimensions": "scalar", + "label": "Gov Debt Contracted Abroad ($D^{ext}_t$)", + "toGDP_label": "External Debt-to-GDP ($D^{ext}_{t}/Y_t$)" + }, + "new_borrowing_ext": { + "desc": "New borrowing of government debt contracted abroad", + "section": "Government Revenues, Outlays, and Debt", + "type": "array-like", + "TPI dimensions": "T", + "SS dimensions": "scalar", + "label": "New External Borrowing", + "toGDP_label": "New External Borrowing-to-GDP" + }, + "debt_service_ext": { + "desc": "Interest on government debt contracted abroad, at r_D_ext", + "section": "Government Revenues, Outlays, and Debt", + "type": "array-like", + "TPI dimensions": "T", + "SS dimensions": "scalar", + "label": "External Debt Service", + "toGDP_label": "External Debt Service-to-GDP" + }, "new_borrowing": { "desc": "New government borrowing, equal to budget deficit", "section": "Government Revenues, Outlays, and Debt", diff --git a/ogcore/output_plots.py b/ogcore/output_plots.py index ff584625d..72f9bab12 100644 --- a/ogcore/output_plots.py +++ b/ogcore/output_plots.py @@ -1005,13 +1005,17 @@ def plot_all(base_output_path, reform_output_path, save_path): path=os.path.join(save_path, "SpendGDPratio.png"), ) - # Debt-GDP in base and reform-- vertical lines at tG1, tG2 + # Debt-GDP in base and reform-- vertical lines at tG1, tG2; with debt + # contracted abroad (D_ext), plot it alongside market debt + debt_vars = ["D"] + if "D_ext" in base_tpi and np.any(np.asarray(base_tpi["D_ext"]) != 0): + debt_vars.append("D_ext") plot_gdp_ratio( base_tpi, base_params, reform_tpi, reform_params, - var_list=["D"], + var_list=debt_vars, num_years_to_plot=min(base_params.T, 150), start_year=base_params.start_year, vertical_line_years=[ diff --git a/ogcore/output_tables.py b/ogcore/output_tables.py index 739834fec..e75599f72 100644 --- a/ogcore/output_tables.py +++ b/ogcore/output_tables.py @@ -195,9 +195,10 @@ def macro_table_SS( if v != "D/Y": diff = ((reform_ss[v] - base_ss[v]) / base_ss[v]) * 100 else: - diff = ( - reform_ss["D"] / reform_ss["Y"] - base_ss["D"] / base_ss["Y"] - ) + # all government debt: market debt plus debt contracted abroad + diff = (reform_ss["D"] + reform_ss.get("D_ext", 0.0)) / reform_ss[ + "Y" + ] - (base_ss["D"] + base_ss.get("D_ext", 0.0)) / base_ss["Y"] table_dict["% Change (or pp diff)"].append(diff) # Make df with dict so can use pandas functions table_df = pd.DataFrame.from_dict( @@ -1199,7 +1200,11 @@ def model_fit_table( elif target_desc == r"Infrastructure spending to GDP ratio $(I_g/Y)$": model_val = tpi_output["I_g"][t] / tpi_output["Y"][t] elif target_desc == r"Debt to GDP ratio $(D/Y)$": - model_val = tpi_output["D"][t] / tpi_output["Y"][t] + # all government debt: market debt plus debt contracted abroad + model_val = ( + tpi_output["D"][t] + + (tpi_output["D_ext"][t] if "D_ext" in tpi_output else 0.0) + ) / tpi_output["Y"][t] # Distributional moments elif target_desc == "Gini coefficient, wealth": dist = tpi_output["b_sp1"][t] diff --git a/ogcore/parameters.py b/ogcore/parameters.py index 33ffcd1a1..d7c6c6386 100644 --- a/ogcore/parameters.py +++ b/ogcore/parameters.py @@ -252,13 +252,13 @@ def compute_default_params(self): "alpha_T", "alpha_I", "alpha_FA", - "alpha_ODA", + "alpha_D_ext", "alpha_bs_G", "alpha_bs_T", "alpha_bs_I", "alpha_bs_FA", "world_int_rate_annual", - "r_ODA_annual", + "r_D_ext_annual", "adjustment_factor_for_cit_receipts", "tau_bq", "h_wealth", @@ -445,9 +445,9 @@ def compute_default_params(self): self.S, ) - # interest rate on concessional (ODA) government debt - self.r_ODA = rate_conversion( - self.r_ODA_annual, + # interest rate on government debt contracted abroad (D_ext) + self.r_D_ext = rate_conversion( + self.r_D_ext_annual, self.starting_age, self.ending_age, self.S, diff --git a/ogcore/utils.py b/ogcore/utils.py index d0677ac55..27ae8c15b 100644 --- a/ogcore/utils.py +++ b/ogcore/utils.py @@ -1357,9 +1357,9 @@ def unstationarize_vars( "UBI_path", "new_borrowing_f", "debt_service_f", - "D_ODA", - "new_borrowing_ODA", - "debt_service_ODA", + "D_ext", + "new_borrowing_ext", + "debt_service_ext", ]: non_stationary_output = tpi_vars[var][:T] * pop_growth * prod_growth elif var in [ diff --git a/tests/test_SS.py b/tests/test_SS.py index 2146efab8..cbf88358f 100644 --- a/tests/test_SS.py +++ b/tests/test_SS.py @@ -8,7 +8,7 @@ import numpy as np import os import pickle -from ogcore import SS, utils, aggregates +from ogcore import SS, utils, aggregates, fiscal from ogcore.parameters import Specifications from ogcore import firm @@ -447,12 +447,13 @@ def test_SS_solver(baseline, param_updates, filename, dask_client): ) -def test_SS_solver_ODA(dask_client): - # With concessional (ODA) debt, the steady state holds the stock at - # its share of GDP, balances the government budget with the ODA flows, - # and clears the goods market with ODA interest paid abroad. +def test_SS_solver_D_ext(dask_client): + # With government debt contracted abroad (D_ext), the steady state + # holds the stock at its share of GDP, balances the government budget + # with its flows, clears the goods market with its interest paid + # abroad, and prices the premium on r_gov at all government debt. p = Specifications(baseline=True, num_workers=NUM_WORKERS) - p.update_specifications({"alpha_ODA": [0.3], "r_ODA_annual": [0.01]}) + p.update_specifications({"alpha_D_ext": [0.3], "r_D_ext_annual": [0.01]}) p.frac_tax_payroll = np.zeros(p.frac_tax_payroll.shape) p.output_base = CUR_PATH b_guess = np.ones((p.S, p.J)) * 0.07 @@ -479,25 +480,30 @@ def test_SS_solver_ODA(dask_client): ) Y = ss["Y"] - assert np.isclose(ss["D_ODA"], 0.3 * Y) + assert np.isclose(ss["D_ext"], 0.3 * Y) assert np.isclose( - ss["new_borrowing_ODA"], + ss["new_borrowing_ext"], 0.3 * Y * ((1 + p.g_n_ss) * np.exp(p.g_y) - 1), ) - assert np.isclose(ss["debt_service_ODA"], p.r_ODA[-1] * 0.3 * Y) + assert np.isclose(ss["debt_service_ext"], p.r_D_ext[-1] * 0.3 * Y) assert np.isclose( ss["G"], ss["total_tax_revenue"] + ss["new_borrowing"] + ss["foreign_aid"] - + ss["new_borrowing_ODA"] - - ss["debt_service_ODA"] + + ss["new_borrowing_ext"] + - ss["debt_service_ext"] - ss["agg_pension_outlays"] - ss["TR"] - ss["debt_service"] - ss["UBI"] - ss["I_g"], ) + # the premium is evaluated at all long-run government debt + assert np.isclose( + ss["r_gov"], + fiscal.get_r_gov(ss["r"], p.debt_ratio_ss + 0.3, p, "scalar", t=-1), + ) assert np.abs(ss["resource_constraint_error"]).max() < 1e-6 diff --git a/tests/test_TPI.py b/tests/test_TPI.py index ed8fb2272..43d9c0b3f 100644 --- a/tests/test_TPI.py +++ b/tests/test_TPI.py @@ -1312,13 +1312,13 @@ def test_run_TPI_extra(baseline, param_updates, filename, tmpdir, dask_client): @pytest.mark.local -def test_run_TPI_ODA(tmpdir, dask_client): +def test_run_TPI_D_ext(tmpdir, dask_client): """ - A baseline transition with concessional (ODA) debt that falls over - time and gets dearer: the stock, its new borrowing and its interest - follow alpha_ODA and r_ODA period by period, the government budget - holds in every period with the ODA flows in it, and the goods market - clears along the path with ODA interest paid abroad. + A baseline transition with government debt contracted abroad (D_ext) + that falls over time and gets dearer: the stock, its new borrowing and + its interest follow alpha_D_ext and r_D_ext period by period, the + government budget holds in every period with these flows in it, and + the goods market clears along the path with the interest paid abroad. """ baseline_dir = os.path.join(tmpdir, "baseline") p = Specifications( @@ -1329,8 +1329,8 @@ def test_run_TPI_ODA(tmpdir, dask_client): ) p.update_specifications( { - "alpha_ODA": [0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0.0], - "r_ODA_annual": [-0.01, 0.0, 0.01, 0.02], + "alpha_D_ext": [0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0.0], + "r_D_ext_annual": [-0.01, 0.0, 0.01, 0.02], } ) SS.ENFORCE_SOLUTION_CHECKS = True @@ -1344,16 +1344,16 @@ def test_run_TPI_ODA(tmpdir, dask_client): Y = tpi["Y"][:T] growth = np.exp(p.g_y) * (1 + p.g_n[:T]) # the stock and its flows - assert np.allclose(tpi["D_ODA"], p.alpha_ODA[:T] * Y) - D_ODA_next = p.alpha_ODA[1 : T + 1] * np.append(Y[1:], Y[-1]) + assert np.allclose(tpi["D_ext"], p.alpha_D_ext[:T] * Y) + D_ext_next = p.alpha_D_ext[1 : T + 1] * np.append(Y[1:], Y[-1]) assert np.allclose( - tpi["new_borrowing_ODA"], D_ODA_next * growth - tpi["D_ODA"] + tpi["new_borrowing_ext"], D_ext_next * growth - tpi["D_ext"] ) - assert np.allclose(tpi["debt_service_ODA"], p.r_ODA[:T] * tpi["D_ODA"]) - assert tpi["D_ODA"][10] == 0.0 + assert np.allclose(tpi["debt_service_ext"], p.r_D_ext[:T] * tpi["D_ext"]) + assert tpi["D_ext"][10] == 0.0 # the government budget, period by period D = tpi["D"] - ODA_net = tpi["new_borrowing_ODA"] - tpi["debt_service_ODA"] + ext_net = tpi["new_borrowing_ext"] - tpi["debt_service_ext"] outlays = ( (1 + tpi["r_gov"][: T - 1]) * D[: T - 1] + tpi["G"][: T - 1] @@ -1363,7 +1363,7 @@ def test_run_TPI_ODA(tmpdir, dask_client): + tpi["agg_pension_outlays"][: T - 1] - tpi["total_tax_revenue"][: T - 1] - tpi["foreign_aid"][: T - 1] - - ODA_net[: T - 1] + - ext_net[: T - 1] ) assert np.allclose(D[1:T] * growth[: T - 1], outlays, atol=1e-8) # the goods market along the path diff --git a/tests/test_fiscal.py b/tests/test_fiscal.py index 7deb7edb6..672dc1f9f 100644 --- a/tests/test_fiscal.py +++ b/tests/test_fiscal.py @@ -484,9 +484,9 @@ def test_get_K_g(K_g0, I_g, method, leakage, expected): ["SS", "TPI"], ids=["SS", "TPI"], ) -def test_get_ODA(method): +def test_get_D_ext(method): """ - Test of the stock, new borrowing, and interest on concessional (ODA) + Test of the stock, new borrowing, and interest on external (D_ext) government debt. """ p = Specifications() @@ -494,11 +494,11 @@ def test_get_ODA(method): p.g_y = 0.03 p.g_n_ss = 0.02 p.g_n = np.array([0.02, 0.01]) - p.alpha_ODA = np.array([0.1, 0.5, 0.5]) - p.r_ODA = np.array([0.01, -0.01, -0.01]) + p.alpha_D_ext = np.array([0.1, 0.5, 0.5]) + p.r_D_ext = np.array([0.01, -0.01, -0.01]) Y = np.array([0.2, 4.0]) if method == "SS": - D_ODA, new_borrowing_ODA, debt_service_ODA = fiscal.get_ODA( + D_ext, new_borrowing_ext, debt_service_ext = fiscal.get_D_ext( Y[-1], p, method ) expected = ( @@ -507,7 +507,7 @@ def test_get_ODA(method): -0.01 * 2.0, ) else: - D_ODA, new_borrowing_ODA, debt_service_ODA = fiscal.get_ODA( + D_ext, new_borrowing_ext, debt_service_ext = fiscal.get_D_ext( Y, p, method ) # the stock in period T uses output in period T - 1 @@ -522,51 +522,51 @@ def test_get_ODA(method): np.array([0.01 * 0.02, -0.01 * 2.0]), ) for test_val, expected_val in zip( - (D_ODA, new_borrowing_ODA, debt_service_ODA), expected + (D_ext, new_borrowing_ext, debt_service_ext), expected ): assert np.allclose(test_val, expected_val) -def test_get_ODA_zero_by_default(): +def test_get_D_ext_zero_by_default(): """ - With the default parameters there is no concessional debt. + With the default parameters there is no debt contracted abroad. """ p = Specifications() Y = np.ones(p.T) * 2.0 for method, y in (("SS", 2.0), ("TPI", Y)): - for v in fiscal.get_ODA(y, p, method): + for v in fiscal.get_D_ext(y, p, method): assert np.allclose(v, 0.0) -def test_get_G_ss_ODA(): +def test_get_G_ss_D_ext(): """ - Concessional debt adds its new borrowing, less its interest, to the - resources that finance steady-state government spending. + Debt contracted abroad adds its new borrowing, less its interest, to + the resources that finance steady-state government spending. """ Y = 2.2 new_borrowing = 0.072076633 debt_service = 0.042345192 p = Specifications() - p.update_specifications({"alpha_ODA": [0.3], "r_ODA_annual": [0.01]}) + p.update_specifications({"alpha_D_ext": [0.3], "r_D_ext_annual": [0.01]}) test_G = fiscal.get_G_ss( Y, 2.3, 0.0, 1.6, 0.0, 0.0, 0.0, new_borrowing, debt_service, p ) - D_ODA = 0.3 * Y + D_ext = 0.3 * Y expected_G = ( expected_G1 - + D_ODA * ((1 + p.g_n_ss) * np.exp(p.g_y) - 1) - - p.r_ODA[-1] * D_ODA + + D_ext * ((1 + p.g_n_ss) * np.exp(p.g_y) - 1) + - p.r_D_ext[-1] * D_ext ) assert np.allclose(test_G, expected_G) -def test_D_G_path_ODA_budget_constraint(): +def test_D_G_path_D_ext_budget_constraint(): """ - With concessional debt, the time path of market debt and spending + With debt contracted abroad, the time path of market debt and spending satisfies the government budget constraint each period: - growth * D_{t+1} + new ODA borrowing_t + Rev_t + FA_t = - (1 + r_gov_t) D_t + ODA interest_t + G_t + I_g_t + TR_t + UBI_t + growth * D_{t+1} + new external borrowing_t + Rev_t + FA_t = + (1 + r_gov_t) D_t + external interest_t + G_t + I_g_t + TR_t + UBI_t + pensions_t. """ p = Specifications() @@ -582,8 +582,8 @@ def test_D_G_path_ODA_budget_constraint(): "rho_G": 0.1, "g_y_annual": 0.03, "alpha_FA": [0.01], - "alpha_ODA": [0.2, 0.25, 0.3], - "r_ODA_annual": [-0.01], + "alpha_D_ext": [0.2, 0.25, 0.3], + "r_D_ext_annual": [-0.01], }, raise_errors=False, ) @@ -605,20 +605,72 @@ def test_D_G_path_ODA_budget_constraint(): 0.59, ) D, G, _, _, r_gov, _, _, _ = fiscal.D_G_path(r, dg_fixed_values, p) - _, new_borrowing_ODA, debt_service_ODA = fiscal.get_ODA(Y_path, p, "TPI") + _, new_borrowing_ext, debt_service_ext = fiscal.get_D_ext(Y_path, p, "TPI") growth = np.exp(p.g_y) * (1 + p.g_n[: p.T - 1]) lhs = ( growth * D[1 : p.T] - + new_borrowing_ODA[: p.T - 1] + + new_borrowing_ext[: p.T - 1] + Revenue[: p.T - 1] + foreign_aid[: p.T - 1] ) rhs = ( (1 + r_gov[: p.T - 1]) * D[: p.T - 1] - + debt_service_ODA[: p.T - 1] + + debt_service_ext[: p.T - 1] + G[: p.T - 1] + TR_path[: p.T - 1] ) assert np.allclose(lhs, rhs) # the closure rule still brings market debt to its target assert np.isclose(D[p.T - 1] / Y_path[p.T - 2], p.debt_ratio_ss) + + +@pytest.mark.parametrize( + "alpha_D_ext", [[0.0], [0.2, 0.25, 0.3]], ids=["none", "some"] +) +def test_D_G_path_premium_on_total_debt(alpha_D_ext): + """ + The debt-elastic premium on r_gov is evaluated at all government debt, + market debt D plus debt contracted abroad D_ext. With no debt + contracted abroad it is the market-debt ratio, as before. + """ + p = Specifications() + p.update_specifications( + { + "T": 320, + "S": 80, + "debt_ratio_ss": 1.2, + "tG1": 20, + "tG2": 256, + "alpha_T": [0.09], + "alpha_G": [0.05], + "rho_G": 0.1, + "g_y_annual": 0.03, + "r_gov_DY": -0.04, + "r_gov_DY2": 0.02, + "alpha_D_ext": alpha_D_ext, + "r_D_ext_annual": [-0.01], + }, + raise_errors=False, + ) + r = np.ones(p.T + p.S) * 0.05 + p.g_n = np.ones(p.T + p.S) * 0.02 + zeros = np.zeros_like(TR) + dg_fixed_values = ( + Y.copy(), + Revenue, + zeros, + zeros, + TR.copy(), + zeros, + zeros[: p.T], + Gbaseline, + 0.59, + ) + D, _, _, _, r_gov, _, _, _ = fiscal.D_G_path(r, dg_fixed_values, p) + D_ext, _, _ = fiscal.get_D_ext(Y, p, "TPI") + total = (D[: p.T] + D_ext) / Y[: p.T] + expected = fiscal.get_r_gov(r[: p.T], total, p, "TPI") + assert np.allclose(r_gov[: p.T], expected) + if alpha_D_ext == [0.0]: + market = fiscal.get_r_gov(r[: p.T], D[: p.T] / Y[: p.T], p, "TPI") + assert np.allclose(r_gov[: p.T], market) diff --git a/tests/test_parameters.py b/tests/test_parameters.py index 0c4a5dd38..c38987350 100644 --- a/tests/test_parameters.py +++ b/tests/test_parameters.py @@ -83,25 +83,25 @@ def test_alpha_FA_extended_over_time_path(): assert specs.alpha_FA[-1] == 0.03 -def test_ODA_parameters_extended_and_converted(): - # Concessional (ODA) debt and its interest rate may vary over the time +def test_D_ext_parameters_extended_and_converted(): + # External debt (D_ext) and its interest rate may vary over the time # path; the annual rate is converted to a model-period rate. specs = Specifications() - assert np.all(specs.alpha_ODA == 0.0) - assert np.all(specs.r_ODA == 0.0) + assert np.all(specs.alpha_D_ext == 0.0) + assert np.all(specs.r_D_ext == 0.0) specs.update_specifications( { - "alpha_ODA": [0.1, 0.2], - "r_ODA_annual": [0.01, -0.02], + "alpha_D_ext": [0.1, 0.2], + "r_D_ext_annual": [0.01, -0.02], } ) - assert specs.alpha_ODA.shape[0] == specs.T + specs.S - assert specs.alpha_ODA[0] == 0.1 - assert specs.alpha_ODA[-1] == 0.2 - assert specs.r_ODA.shape[0] == specs.T + specs.S + assert specs.alpha_D_ext.shape[0] == specs.T + specs.S + assert specs.alpha_D_ext[0] == 0.1 + assert specs.alpha_D_ext[-1] == 0.2 + assert specs.r_D_ext.shape[0] == specs.T + specs.S years_per_period = (specs.ending_age - specs.starting_age) / specs.S - assert np.isclose(specs.r_ODA[0], 1.01**years_per_period - 1) - assert np.isclose(specs.r_ODA[-1], 0.98**years_per_period - 1) + assert np.isclose(specs.r_D_ext[0], 1.01**years_per_period - 1) + assert np.isclose(specs.r_D_ext[-1], 0.98**years_per_period - 1) def test_tau_payroll_extended_over_T_and_J(): From 6e237bee7dfb93bbb752ac92eba4c4dc5e67c520 Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Wed, 18 Nov 2026 16:50:09 -0500 Subject: [PATCH 5/6] Note that debt contracted abroad held at a share of GDP gives the long-run budget a net inflow from abroad when its rate is below growth, and that phasing alpha_D_ext to zero avoids it (review by arihantlodha-cmd) --- docs/book/content/theory/government.md | 2 +- ogcore/default_parameters.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/book/content/theory/government.md b/docs/book/content/theory/government.md index a879c42c2..a51caa83c 100644 --- a/docs/book/content/theory/government.md +++ b/docs/book/content/theory/government.md @@ -750,7 +750,7 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul D^{ext}_t = \alpha_{D,ext,t}\: Y_t \quad\forall t ``` - The government receives the new external borrowing $D^{ext}_{t+1} - D^{ext}_t$ and pays the interest $r_{ext,t}D^{ext}_t$ each period. Debt contracted abroad is separate from the market debt $D_t$: it is not part of household savings, so it does not enter the household portfolio return $r_{p,t}$ in {eq}`eq_portfolio_return`, and the debt-to-GDP target $\alpha_D$ of the budget closure rule and the share of new market debt bought by foreigners $\zeta_D$ refer to market debt; $D^f_t$ is then the part of market debt held by foreigners. The debt-elastic premium on $r_{gov,t}$ in {eq}`EqUnbalGBC_rate_wedge` is evaluated at all government debt, $D_t + D^{ext}_t$. Its interest is paid abroad at $r_{ext,t}$ in the goods market clearing condition (Chapter {ref}`Chap_MarkClr`). Because the stock is set by $\alpha_{D,ext,t}$, a reform that changes borrowing changes market debt only, unless it also changes $\alpha_{D,ext,t}$; and in the steady state all government debt is $\alpha_D + \alpha_{D,ext}$ of GDP. By default $\alpha_{D,ext,t} = 0$. + The government receives the new external borrowing $D^{ext}_{t+1} - D^{ext}_t$ and pays the interest $r_{ext,t}D^{ext}_t$ each period. Debt contracted abroad is separate from the market debt $D_t$: it is not part of household savings, so it does not enter the household portfolio return $r_{p,t}$ in {eq}`eq_portfolio_return`, and the debt-to-GDP target $\alpha_D$ of the budget closure rule and the share of new market debt bought by foreigners $\zeta_D$ refer to market debt; $D^f_t$ is then the part of market debt held by foreigners. The debt-elastic premium on $r_{gov,t}$ in {eq}`EqUnbalGBC_rate_wedge` is evaluated at all government debt, $D_t + D^{ext}_t$. Its interest is paid abroad at $r_{ext,t}$ in the goods market clearing condition (Chapter {ref}`Chap_MarkClr`). Because the stock is set by $\alpha_{D,ext,t}$, a reform that changes borrowing changes market debt only, unless it also changes $\alpha_{D,ext,t}$; and in the steady state all government debt is $\alpha_D + \alpha_{D,ext}$ of GDP. In the steady state the stock grows with GDP, so the government borrows $\left[(1+g_n)e^{g_y} - 1\right]D^{ext}$ a period and pays $r_{ext}D^{ext}$ in interest: when $r_{ext}$ is below the growth rate, as concessional rates usually are, the long-run budget receives a permanent net inflow from abroad. (Market debt held at $\alpha_D$ has the same property whenever $r_{gov}$ is below growth; the difference is that $r_{ext}$ is set by the user.) Phasing $\alpha_{D,ext,t}$ down to zero, for example as the debt is repaid, avoids it. By default $\alpha_{D,ext,t} = 0$. Aggregate spending on UBI at time $t$ is the sum of UBI payments across all households at time $t$: diff --git a/ogcore/default_parameters.json b/ogcore/default_parameters.json index 67d8055fe..da9ceb69c 100644 --- a/ogcore/default_parameters.json +++ b/ogcore/default_parameters.json @@ -1004,7 +1004,7 @@ }, "alpha_D_ext": { "title": "Government debt contracted abroad as a share of GDP", - "description": "Stock of government debt contracted abroad at its own interest rate, as a share of GDP: for example concessional loans from multilateral and bilateral lenders (official development assistance), or bonds and loans on commercial terms. This debt is held only by foreigners and is not part of the market debt D: it does not enter households' portfolio return, pays r_D_ext_annual, and is paid abroad at that rate. The debt-elastic premium on r_gov is evaluated at all government debt, D plus this debt, while the budget closure rule (debt_ratio_ss) and zeta_D refer to market debt. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered.", + "description": "Stock of government debt contracted abroad at its own interest rate, as a share of GDP: for example concessional loans from multilateral and bilateral lenders (official development assistance), or bonds and loans on commercial terms. This debt is held only by foreigners and is not part of the market debt D: it does not enter households' portfolio return, pays r_D_ext_annual, and is paid abroad at that rate. The debt-elastic premium on r_gov is evaluated at all government debt, D plus this debt, while the budget closure rule (debt_ratio_ss) and zeta_D refer to market debt. In the steady state the stock grows with GDP, so when r_D_ext_annual is below the growth rate the long-run budget receives a net inflow from abroad each period (new borrowing exceeds interest); phase alpha_D_ext down to zero to avoid it. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered.", "short_description": "Government debt contracted abroad as a share of GDP", "param_notation": "$\\alpha_{D,ext,t}$", "section_1": "Fiscal Policy Parameters", From 7e0599ab8182f1ff050aab0773a287153b0b5870 Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Wed, 18 Nov 2026 17:11:25 -0500 Subject: [PATCH 6/6] A reform starts from the baseline's debt contracted abroad: the stock owed in period 0 is inherited, as market debt and public capital are, so it no longer moves with reform output; later periods follow alpha_D_ext. The first period's new borrowing and the debt premium use the inherited stock. Test, docs and changelog (review by autibet on EAPD-DRB/OG-ETH#111) --- CHANGELOG.md | 2 +- docs/book/content/theory/government.md | 2 +- ogcore/TPI.py | 18 ++++++++++--- ogcore/fiscal.py | 10 +++++++ tests/test_fiscal.py | 37 ++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 812d92bf0..1636777a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Adds - Adds government debt contracted abroad at its own interest rate, addressing Issue #1125 (concessional debt from official lenders), and usable for any government debt contracted abroad, concessional or commercial. The new time-varying parameter `alpha_D_ext` (default 0.0) sets this debt as a share of GDP, and `r_D_ext_annual` (default 0.0, time varying, converted to a model-period rate `r_D_ext`) its real interest rate. Each period the government receives the new external borrowing and pays its interest, in the budget constraint of the steady state and the time path (`fiscal.D_G_path`, `fiscal.get_G_ss`, and the balanced-budget case of `fiscal.get_TR`), and the interest is paid abroad at `r_D_ext` in the resource constraint. The debt is held only by foreigners and is separate from the market debt `D`: it does not enter households' portfolio return `r_p`, and `debt_ratio_ss`, the closure rule and `zeta_D` refer to market debt. - Adds `fiscal.get_D_ext`, which returns the stock of debt contracted abroad, new external borrowing, and its interest in the steady state or along the time path. -- Adds `D_ext`, `new_borrowing_ext`, and `debt_service_ext` to the steady-state and time-path output (with their descriptions in `model_variables.json`, and in `utils.unstationarize_vars`), and includes external interest in `total_government_outlays`. The debt is a share of GDP in the reform as well, including when `baseline_spending=True`. +- Adds `D_ext`, `new_borrowing_ext`, and `debt_service_ext` to the steady-state and time-path output (with their descriptions in `model_variables.json`, and in `utils.unstationarize_vars`), and includes external interest in `total_government_outlays`. The debt is a share of GDP in the reform as well, including when `baseline_spending=True`, except in the first period: a reform starts from the baseline's stock, as it does for market debt and public capital. - Adds the debt contracted abroad to the government budget constraint, the budget closure rules, and their stationarized forms in the documentation, and adds it and foreign aid to the goods market clearing condition. - Adds tests of `fiscal.get_D_ext`, of the steady-state spending and the time path of debt and spending with debt contracted abroad (the budget constraint holds each period), of the premium on total debt, of the new parameters, a steady-state solution that balances the budget and clears the goods market, and a time path (marked `local`) with a falling external debt that keeps the budget and the goods market in balance in every period. - Adds the building blocks of a funded defined contribution (FDC) pension pillar, which runs alongside whichever `pension_system` is selected. This change adds the parameters and the account calculations; the household problem, aggregates, steady state, and time path do not use them yet, so model results are unchanged. diff --git a/docs/book/content/theory/government.md b/docs/book/content/theory/government.md index a51caa83c..6ca9c9e85 100644 --- a/docs/book/content/theory/government.md +++ b/docs/book/content/theory/government.md @@ -653,7 +653,7 @@ Foreign aid to the domestic government, $FA_t$, is treated the same way. In the This means that changes to `alpha_FA` in the reform have no effect when `baseline_spending=True`; use `alpha_bs_FA` to change the level of foreign aid relative to the baseline instead. -Debt contracted abroad $D^{ext}_t$ is not affected by `baseline_spending`: in the reform simulation it is always the fraction $\alpha_{D,ext,t}$ of GDP in the reform. +Debt contracted abroad $D^{ext}_t$ is not affected by `baseline_spending`. In a reform simulation the stock owed in the first period is the baseline's, since debt already owed when the reform begins cannot depend on it (as with market debt $D_0$ and public capital); from the second period on it is the fraction $\alpha_{D,ext,t}$ of GDP in the reform. Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRule`}) still takes effect in the case of `baseline_spending=True`. What this means is that the relation described above holds until the period in which the closure rules takes effect. Once the closure rule begins, the path of $G$ (and/or $TR$, depending on the closure rule used) will adjust as determined by the rule to close the government budget in the long run. diff --git a/ogcore/TPI.py b/ogcore/TPI.py index adc1456d6..a7a4f9296 100644 --- a/ogcore/TPI.py +++ b/ogcore/TPI.py @@ -421,9 +421,17 @@ def get_initial_SS_values(p): b_splus1init[:-1, :] = b_sinit[1:, :] D0_baseline = tpi_baseline_vars["D"][0] Kg0_baseline = tpi_baseline_vars["K_g"][0] + # debt contracted abroad owed in period 0 is inherited too + # (fiscal.get_D_ext reads it); baselines saved before D_ext was + # an output fall back to alpha_D_ext times reform output + if "D_ext" in tpi_baseline_vars: + p.D_ext0_baseline = float(tpi_baseline_vars["D_ext"][0]) + else: + p.D_ext0_baseline = None else: D0_baseline = None Kg0_baseline = None + p.D_ext0_baseline = None initial_values = (B0, b_sinit, b_splus1init, factor, initial_n) baseline_values = ( @@ -1295,9 +1303,13 @@ def run_TPI(p, client=None): # Compute other interest rates r_gov = np.ones_like(r) * ss_vars["r_gov"] # the debt-elastic premium prices all government debt: market debt D - # plus debt contracted abroad, D_ext = alpha_D_ext * Y + # plus debt contracted abroad, D_ext (alpha_D_ext * Y, with a reform's + # period-0 stock at the baseline's) r_gov[: p.T] = fiscal.get_r_gov( - r[: p.T], D[: p.T] / Y[: p.T] + p.alpha_D_ext[: p.T], p, "TPI" + r[: p.T], + (D[: p.T] + fiscal.get_D_ext(Y, p, "TPI")[0]) / Y[: p.T], + p, + "TPI", ) r_p = np.ones_like(r) * ss_vars["r_p"] MPKg = np.zeros((p.T, p.M)) @@ -1750,7 +1762,7 @@ def run_TPI(p, client=None): ) r_gov_new = fiscal.get_r_gov( rnew[: p.T], - Dnew[: p.T] / Y[: p.T] + p.alpha_D_ext[: p.T], + (Dnew[: p.T] + fiscal.get_D_ext(Y, p, "TPI")[0]) / Y[: p.T], p, "TPI", ) diff --git a/ogcore/fiscal.py b/ogcore/fiscal.py index 9a286f13a..52ff9035e 100644 --- a/ogcore/fiscal.py +++ b/ogcore/fiscal.py @@ -554,6 +554,10 @@ def get_D_ext(Y, p, method="SS"): \text{external debt service}_t &= r_{ext,t}\hat{D}^{ext}_{t} \end{split} + In a reform's time path the period-0 stock is the baseline's + (``p.D_ext0_baseline``), since debt already owed when the reform + begins cannot depend on it; later periods follow alpha_D_ext. + Args: Y (array_like): aggregate output p (OG-Core Specifications object): model parameters @@ -577,6 +581,12 @@ def get_D_ext(Y, p, method="SS"): # last value forward. Y_path = np.append(Y[: p.T], Y[p.T - 1]) D_ext = p.alpha_D_ext[: p.T + 1] * Y_path + # In a reform the debt the economy starts with is inherited: it + # stays at the baseline's period-0 level, as market debt and + # public capital do (set in TPI.get_initial_SS_values) + D_ext0 = getattr(p, "D_ext0_baseline", None) + if not p.baseline and D_ext0 is not None: + D_ext[0] = D_ext0 new_borrowing_ext = ( D_ext[1:] * np.exp(p.g_y) * (1 + p.g_n[: p.T]) - D_ext[:-1] ) diff --git a/tests/test_fiscal.py b/tests/test_fiscal.py index 672dc1f9f..1923606d0 100644 --- a/tests/test_fiscal.py +++ b/tests/test_fiscal.py @@ -527,6 +527,43 @@ def test_get_D_ext(method): assert np.allclose(test_val, expected_val) +def test_get_D_ext_reform_keeps_baseline_initial_stock(): + """ + In a reform's time path the debt contracted abroad that is owed in + period 0 is the baseline's, not alpha_D_ext times reform output; later + periods follow alpha_D_ext, and the first period's new borrowing is + measured from the inherited stock. The baseline is unaffected. + """ + p = Specifications() + p.T = 2 + p.g_y = 0.03 + p.g_n = np.array([0.02, 0.01]) + p.alpha_D_ext = np.array([0.1, 0.5, 0.5]) + p.r_D_ext = np.array([0.01, -0.01, -0.01]) + Y = np.array([0.2, 4.0]) + p.D_ext0_baseline = 0.03 + p.baseline = False + D_ext, new_borrowing_ext, debt_service_ext = fiscal.get_D_ext(Y, p, "TPI") + assert np.allclose(D_ext, [0.03, 2.0]) + assert np.allclose( + new_borrowing_ext, + [ + 2.0 * np.exp(0.03) * 1.02 - 0.03, + 2.0 * np.exp(0.03) * 1.01 - 2.0, + ], + ) + assert np.allclose(debt_service_ext, [0.01 * 0.03, -0.01 * 2.0]) + # the baseline ignores the attribute + p.baseline = True + D_ext, _, _ = fiscal.get_D_ext(Y, p, "TPI") + assert np.allclose(D_ext, [0.02, 2.0]) + # a reform whose baseline predates D_ext keeps the ratio + p.baseline = False + p.D_ext0_baseline = None + D_ext, _, _ = fiscal.get_D_ext(Y, p, "TPI") + assert np.allclose(D_ext, [0.02, 2.0]) + + def test_get_D_ext_zero_by_default(): """ With the default parameters there is no debt contracted abroad.