Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/book/content/theory/government.md
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,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$ 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 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$,

```{math}
:label: EqUnbalGBCbudgConstr
D_{t+1} + Rev_t = (1 + r_{gov,t})D_t + G_t + I_{g,t} + Pensions_t + TR_t + UBI_t \quad\forall t
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
```

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$).
Expand Down Expand Up @@ -713,8 +713,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}}{\alpha_g Y_t} \quad\text{if}\quad T_{G1}\leq t<T_{G2} \\
\frac{\alpha_{D}Y_{t} - (1+r_{gov,t})D_{t} - I_{g,t} - TR_{t} - UBI_{t} + Rev_{t}}{\alpha_g Y_t} \qquad\qquad\quad\:\:\,\text{if}\quad t \geq T_{G2}
\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<T_{G2} \\
\frac{\alpha_{D}Y_{t} - (1+r_{gov,t})D_{t} - I_{g,t} - TR_{t} - UBI_{t} + Rev_{t} + FA_{t}}{\alpha_g Y_t} \qquad\qquad\quad\:\:\,\text{if}\quad t \geq T_{G2}
\end{cases} \\
&\text{and}\quad g_{tr,t} = 1 \quad\forall t
\end{split}
Expand All @@ -735,8 +735,8 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul
&\text{where}\quad g_{tr,t} =
\begin{cases}
1 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\:\:\:\,\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} - G_{t} - I_{g,t} - UBI_{t} + Rev_{t}}{\alpha_{tr} Y_t} \quad\text{if}\quad T_{G1}\leq t<T_{G2} \\
\frac{\alpha_{D}Y_{t} - (1+r_{gov,t})D_{t} - G_{t} - I_{g,t} - UBI_{t} + Rev_{t}}{\alpha_{tr}Y_t} \qquad\qquad\quad\:\:\:\text{if}\quad t \geq T_{G2}
\frac{\left[\rho_{d}\alpha_{D}Y_{t} + (1-\rho_{d})D_{t}\right] - (1+r_{gov,t})D_{t} - G_{t} - I_{g,t} - UBI_{t} + Rev_{t} + FA_{t}}{\alpha_{tr} Y_t} \quad\text{if}\quad T_{G1}\leq t<T_{G2} \\
\frac{\alpha_{D}Y_{t} - (1+r_{gov,t})D_{t} - G_{t} - I_{g,t} - UBI_{t} + Rev_{t} + FA_{t}}{\alpha_{tr}Y_t} \qquad\qquad\quad\:\:\:\text{if}\quad t \geq T_{G2}
\end{cases} \\
&\text{and}\quad g_{g,t} = 1 \quad\forall t
\end{split}
Expand Down Expand Up @@ -766,8 +766,8 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul
&\text{where}\quad g_{trg,t} =
\begin{cases}
1 \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} - UBI_{t} + Rev_{t}}{\left(\alpha_g + \alpha_{tr}\right)Y_t} \quad\text{if}\quad T_{G1}\leq t<T_{G2} \\
\frac{\alpha_{D}Y_{t} - (1+r_{gov,t})D_{t} - I_{g,t} - UBI_{t} + Rev_{t}}{\left(\alpha_g + \alpha_{tr}\right)Y_t} \qquad\qquad\quad\:\:\:\text{if}\quad t \geq T_{G2}
\frac{\left[\rho_{d}\alpha_{D}Y_{t} + (1-\rho_{d})D_{t}\right] - (1+r_{gov,t})D_{t} - I_{g,t} - UBI_{t} + Rev_{t} + FA_{t}}{\left(\alpha_g + \alpha_{tr}\right)Y_t} \quad\text{if}\quad T_{G1}\leq t<T_{G2} \\
\frac{\alpha_{D}Y_{t} - (1+r_{gov,t})D_{t} - I_{g,t} - UBI_{t} + Rev_{t} + FA_{t}}{\left(\alpha_g + \alpha_{tr}\right)Y_t} \qquad\qquad\quad\:\:\:\text{if}\quad t \geq T_{G2}
\end{cases}
\end{split}
```
Expand Down
14 changes: 7 additions & 7 deletions docs/book/content/theory/stationarization.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ The usual definition of equilibrium would be allocations and prices such that ho

```{math}
:label: EqStnrzGovBC
e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\hat{D}_{t+1} + \hat{Rev}_t = (1 + r_{gov,t})\hat{D}_t + \hat{G}_t + \hat{I}_{g,t} + \hat{Pensions}_t + \hat{TR}_t + \hat{UBI}_t \quad\forall t
e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\hat{D}_{t+1} + \hat{Rev}_t + \hat{FA}_t = (1 + r_{gov,t})\hat{D}_t + \hat{G}_t + \hat{I}_{g,t} + \hat{Pensions}_t + \hat{TR}_t + \hat{UBI}_t \quad\forall t
```

The stationarized versions of the rule for total government infrastructure investment spending $I_{g,t}$ in {eq}`EqUnbalGBC_Igt` and the rule for government investment spending in each industry in {eq}`EqUnbalGBC_Igt` are found by dividing both sides of the respective equations by $e^{g_y t}\tilde{N}_t$.
Expand Down Expand Up @@ -298,8 +298,8 @@ The usual definition of equilibrium would be allocations and prices such that ho
&\text{where}\quad g_{g,t} =
\begin{cases}
1 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\text{if}\quad t < T_{G1} \\
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\left[\rho_{d}\alpha_{D}\hat{Y}_{t} + (1-\rho_{d})\hat{D}_{t}\right] - (1+r_{gov,t})\hat{D}_{t} - \hat{TR}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t}}{\alpha_g \hat{Y}_t} \:\text{if}\: T_{G1}\leq t<T_{G2} \\
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\alpha_{D}\hat{Y}_{t} - (1+r_{gov,t})\hat{D}_{t} - \hat{TR}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t}}{\alpha_g \hat{Y}_t} \qquad\qquad\quad\,\text{if}\quad t \geq T_{G2}
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\left[\rho_{d}\alpha_{D}\hat{Y}_{t} + (1-\rho_{d})\hat{D}_{t}\right] - (1+r_{gov,t})\hat{D}_{t} - \hat{TR}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t} + \hat{FA}_t}{\alpha_g \hat{Y}_t} \:\text{if}\: T_{G1}\leq t<T_{G2} \\
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\alpha_{D}\hat{Y}_{t} - (1+r_{gov,t})\hat{D}_{t} - \hat{TR}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t} + \hat{FA}_t}{\alpha_g \hat{Y}_t} \qquad\qquad\quad\,\text{if}\quad t \geq T_{G2}
\end{cases} \\
&\text{and}\quad g_{tr,t} = 1 \quad\forall t
\end{split}
Expand All @@ -313,8 +313,8 @@ The usual definition of equilibrium would be allocations and prices such that ho
&\text{where}\quad g_{tr,t} =
\begin{cases}
1 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\:\:\:\text{if}\quad t < T_{G1} \\
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\left[\rho_{d}\alpha_{D}\hat{Y}_{t} + (1-\rho_{d})\hat{D}_{t}\right] - (1+r_{gov,t})\hat{D}_{t} - \hat{G}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t}}{\alpha_{tr} \hat{Y}_t} \:\text{if}\: T_{G1}\leq t<T_{G2} \\
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\alpha_{D}\hat{Y}_{t} - (1+r_{gov,t})\hat{D}_{t} - \hat{G}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t}}{\alpha_{tr} \hat{Y}_t} \qquad\qquad\quad\,\text{if}\quad t \geq T_{G2}
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\left[\rho_{d}\alpha_{D}\hat{Y}_{t} + (1-\rho_{d})\hat{D}_{t}\right] - (1+r_{gov,t})\hat{D}_{t} - \hat{G}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t} + \hat{FA}_t}{\alpha_{tr} \hat{Y}_t} \:\text{if}\: T_{G1}\leq t<T_{G2} \\
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\alpha_{D}\hat{Y}_{t} - (1+r_{gov,t})\hat{D}_{t} - \hat{G}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t} + \hat{FA}_t}{\alpha_{tr} \hat{Y}_t} \qquad\qquad\quad\,\text{if}\quad t \geq T_{G2}
\end{cases} \\
&\text{and}\quad g_{g,t} = 1 \quad\forall t
\end{split}
Expand All @@ -328,8 +328,8 @@ The usual definition of equilibrium would be allocations and prices such that ho
&\text{where}\quad g_{trg,t} =
\begin{cases}
1 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\:\quad \text{if}\quad t < T_{G1} \\
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\left[\rho_{d}\alpha_{D}\hat{Y}_{t} + (1-\rho_{d})\hat{D}_{t}\right] - (1+r_{gov,t})\hat{D}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t}}{\left(\alpha_g + \alpha_{tr}\right)\hat{Y}_t} \:\text{if}\: T_{G1}\leq t<T_{G2} \\
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\alpha_{D}\hat{Y}_{t} - (1+r_{gov,t})\hat{D}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t}}{\left(\alpha_g + \alpha_{tr}\right)\hat{Y}_t} \qquad\qquad\quad\,\text{if}\quad t \geq T_{G2}
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\left[\rho_{d}\alpha_{D}\hat{Y}_{t} + (1-\rho_{d})\hat{D}_{t}\right] - (1+r_{gov,t})\hat{D}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t} + \hat{FA}_t}{\left(\alpha_g + \alpha_{tr}\right)\hat{Y}_t} \:\text{if}\: T_{G1}\leq t<T_{G2} \\
\frac{e^{g_y}\left(1 + \tilde{g}_{n,t+1}\right)\alpha_{D}\hat{Y}_{t} - (1+r_{gov,t})\hat{D}_{t} - \hat{I}_{g,t} - \hat{UBI}_t + \hat{Rev}_{t} + \hat{FA}_t}{\left(\alpha_g + \alpha_{tr}\right)\hat{Y}_t} \qquad\qquad\quad\,\text{if}\quad t \geq T_{G2}
\end{cases}
\end{split}
```
Expand Down
4 changes: 3 additions & 1 deletion ogcore/SS.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,8 @@ def SS_solver(
net_capital_outflows_vec[-1] = net_capital_outflows
RM_vec_ss = np.zeros(p.M)
RM_vec_ss[-1] = RM_ss

foreign_aid_vec_ss = np.zeros(p.M)
foreign_aid_vec_ss[-1] = p.alpha_FA[-1] * Yss
RC = aggr.resource_constraint(
Y_vec_ss,
C_m_vec_ss,
Expand All @@ -1124,6 +1125,7 @@ def SS_solver(
I_g_vec_ss,
net_capital_outflows_vec,
RM_vec_ss,
foreign_aid_vec_ss,
)
logger.info(f"Foreign debt holdings = {D_f_ss}")
logger.info(f"Foreign capital holdings = {K_f_ss}")
Expand Down
3 changes: 3 additions & 0 deletions ogcore/TPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,8 @@ def run_TPI(p, client=None):
net_capital_outflows_vec[:, -1] = net_capital_outflows[: p.T]
RM_vec = np.zeros((p.T, p.M))
RM_vec[:, -1] = RM[: p.T]
foreign_aid_vec = np.zeros((p.T, p.M))
foreign_aid_vec[:, -1] = p.alpha_FA[: p.T] * Y[: p.T]
RC_error = aggr.resource_constraint(
Y_vec,
C_m_vec,
Expand All @@ -1401,6 +1403,7 @@ def run_TPI(p, client=None):
I_g_vec,
net_capital_outflows_vec,
RM_vec,
foreign_aid_vec,
)
# Compute total investment (not just domestic)
I_total = aggr.get_I(None, K[1 : p.T + 1], K[: p.T], p, "total_tpi")
Expand Down
8 changes: 5 additions & 3 deletions ogcore/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def get_r_p(r, r_gov, p_m, K_vec, K_g, D, MPKg_vec, p, method):
return np.squeeze(r_p)


def resource_constraint(Y, C, G, I_d, I_g, net_capital_flows, RM):
def resource_constraint(Y, C, G, I_d, I_g, net_capital_flows, RM, foreign_aid):
r"""
Compute the error in the resource constraint.

Expand All @@ -518,7 +518,8 @@ def resource_constraint(Y, C, G, I_d, I_g, net_capital_flows, RM):
\text{rc_error} &= \hat{Y}_t - \hat{C}_t -
\Bigl(e^{g_y}\bigl[1 + \tilde{g}_{n,t+1}\bigr]\hat{K}^d_{t+1} -
\hat{K}^d_t\Bigr) - \delta\hat{K}_t - \hat{G}_t - \hat{I}_{g,t} ... \\
&\qquad -\: \hat{\text{net capital outflows}}_t + \hat{RM}_t
&\qquad -\: \hat{\text{net capital outflows}}_t + \hat{RM}_t +
\hat{\text{foreign aid}}_t
\end{split}

Args:
Expand All @@ -529,12 +530,13 @@ def resource_constraint(Y, C, G, I_d, I_g, net_capital_flows, RM):
I_g (array_like): investment in government capital
net_capital_flows (array_like): net capital outflows
RM (array_like): aggregate remittances
foreign_aid (array_like): foreign aid payments

Returns:
rc_error (array_like): error in the resource constraint

"""
rc_error = Y - C - I_d - I_g - G - net_capital_flows + RM
rc_error = Y - C - I_d - I_g - G - net_capital_flows + RM + foreign_aid

return rc_error

Expand Down
24 changes: 24 additions & 0 deletions ogcore/default_parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,30 @@
}
}
},
"alpha_FA": {
"title": "Foreign aid payments to domestic government as a share of GDP",
"description": "Foreign aid payments to domestic government as a share of GDP.",
"short_description": "Foreign aid as a share of GDP",
"param_notation": "$\\alpha_{FA}$",
"section_1": "Fiscal Policy Parameters",
"section_2": "Fiscal Policy Parameters",
"notes": "",
"number_dims": 1,
"type": "float",
"value": [
{
"value": [
0.0
]
}
],
"validators": {
"range": {
"min": 0.0,
"max": 1.0
}
}
},
"alpha_RM_1": {
"title": "Exogenous ratio of aggregate remittances to GDP in current period (t=1)",
"description": "Exogenous ratio of aggregate remittances to GDP in current period (t=1).",
Expand Down
21 changes: 19 additions & 2 deletions ogcore/fiscal.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def D_G_path(r, dg_fixed_values, p):
else:
G = p.alpha_G[: p.T] * Y[: p.T]

# direct foreign aid
foreign_aid = p.alpha_FA[: p.T] * Y[: p.T]

if p.budget_balance:
D = np.zeros(p.T + 1)
G = p.alpha_G[: p.T] * Y[: p.T]
Expand All @@ -116,6 +119,7 @@ def D_G_path(r, dg_fixed_values, p):
+ UBI_outlays[t - 1]
+ agg_pension_outlays[t - 1]
- total_tax_revenue[t - 1]
- foreign_aid[t - 1]
)
r_gov[t] = get_r_gov(r[t], D[t] / Y[t], p, method="scalar", t=t)
if (t >= p.tG1) and (t < p.tG2):
Expand All @@ -124,6 +128,7 @@ def D_G_path(r, dg_fixed_values, p):
* (p.rho_G * p.debt_ratio_ss * Y[t] + (1 - p.rho_G) * D[t])
- (1 + r_gov[t]) * D[t]
+ total_tax_revenue[t]
+ foreign_aid[t]
- agg_pension_outlays[t]
- I_g[t - 1]
- TR[t]
Expand All @@ -134,6 +139,7 @@ def D_G_path(r, dg_fixed_values, p):
growth[t + 1] * (p.debt_ratio_ss * Y[t])
- (1 + r_gov[t]) * D[t]
+ total_tax_revenue[t]
+ foreign_aid[t]
- agg_pension_outlays[t]
- I_g[t - 1]
- TR[t]
Expand All @@ -152,12 +158,14 @@ def D_G_path(r, dg_fixed_values, p):
+ UBI_outlays[t - 1]
+ agg_pension_outlays[t - 1]
- total_tax_revenue[t - 1]
- foreign_aid[t - 1]
)
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]
- agg_pension_outlays[t]
- I_g[t - 1]
- TR[t]
Expand All @@ -171,6 +179,7 @@ def D_G_path(r, dg_fixed_values, p):
+ UBI_outlays[t]
+ agg_pension_outlays[t]
- total_tax_revenue[t]
- foreign_aid[t]
)
D_ratio_max = np.amax(D[: p.T] / Y[: p.T])
print("Maximum debt ratio: ", D_ratio_max)
Expand Down Expand Up @@ -284,12 +293,14 @@ def get_G_ss(
G (tuple): steady-state government spending

"""
foreign_aid = p.alpha_FA * Y
if p.budget_balance:
G = p.alpha_G[-1] * Y
else:
G = (
total_tax_revenue
+ new_borrowing
+ foreign_aid
- (agg_pension_outlays + TR + debt_service + UBI_outlays + I_g)
)

Expand Down Expand Up @@ -354,9 +365,15 @@ def get_TR(
new_TR (array_like): new value of aggregate government transfers

"""
foreign_aid = p.alpha_FA * Y
if p.budget_balance:
new_TR = (
total_tax_revenue - agg_pension_outlays - G - UBI_outlays - I_g
total_tax_revenue
+ foreign_aid
- agg_pension_outlays
- G
- UBI_outlays
- I_g
)
elif p.baseline_spending:
new_TR = p.alpha_bs_T[-1] * TR
Expand Down Expand Up @@ -422,7 +439,7 @@ def get_I_g(Y, Ig_baseline, p, method="SS"):
Args:
Y (array_like): aggregate output
Ig_baseline (array_like): public infrastructure investment in
the baseliine simulation
the baseline simulation
p (OG-Core Specifications object): model parameters
method (str): either 'SS' for steady-state or 'TPI' for transition path

Expand Down
13 changes: 0 additions & 13 deletions tests/test_aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1764,22 +1764,9 @@ def test_resource_constraint(
"""
Test resource constraint equation.
"""
# Y = np.array([48, 55, 2, 99, 8])
# C = np.array([33, 44, 0.4, 55, 6])
# G = np.array([4, 5, 0.01, 22, 0])
# I_d = np.array([20, 5, 0.6, 10, 1])
# I_g = np.zeros_like(I_d)
# net_capital_flows = np.array([0.1, 0, 0.016, -1.67, -0.477])
# RM1 = np.array([0.0, 0.0, 0.0, 0.0, 0.0])
# expected1 = np.array([-9.1, 1, 0.974, 13.67, 1.477])
test_RC = aggr.resource_constraint(
Y, C, G, I_d, I_g, net_capital_flows, RM
)
# RM2 = np.array([0.0, 0.0, 0.0, 0.0, 0.03])
# expected2 = np.array([-9.1, 1, 0.974, 13.67, 1.477])
# test_RC2 = aggr.resource_constraint(
# Y, C, G, I_d, I_g, net_capital_flows, RM2
# )

assert np.allclose(test_RC, expected)

Expand Down
12 changes: 12 additions & 0 deletions tests/test_fiscal.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ def test_D_G_path(
"budget_balance": budget_balance,
"r_gov_DY": r_gov_DY,
"r_gov_DY2": r_gov_DY2,
"alpha_FA": [0.01],
}
p.update_specifications(new_param_values, raise_errors=False)
r = np.ones(p.T + p.S) * 0.05
p.g_n = np.ones(p.T + p.S) * 0.02
growth = (1 + p.g_n) * np.exp(p.g_y)
D0_baseline = 0.59
Gbaseline[0] = 0.05
I_g = np.zeros_like(TR)
Expand All @@ -130,8 +132,18 @@ def test_D_G_path(
D0_baseline,
)
test_tuple = fiscal.D_G_path(r, dg_fixed_values, p)
# update expected value for no-zero foreign aid
foreign_aid = p.alpha_FA[: p.T] * Y[: p.T] / (growth[1 : p.T + 1])
# expected_tuple[0][1: p.T] = expected_tuple[0][1: p.T] + foreign_aid[0: p.T-1] # Debt
# expected_tuple[1][: p.T] = expected_tuple[1][: p.T] + (p.alpha_FA[: p.T] * Y[: p.T] / (1+growth[:p.T])) # G
# expected_tuple[2][: p.T] = expected_tuple[2][1: p.T] - (p.alpha_FA[: p.T] * Y[: p.T] / (1+growth[:p.T])) # Domestically held debt
# expected_tuple[5][: p.T] = expected_tuple[5][: p.T] - (p.alpha_FA[: p.T] * Y[: p.T] / (1+growth[:p.T])) # New borrowing
print("Foreign aid = ", foreign_aid[:10])
print("Debt diff = ", test_tuple[0][:10] - expected_tuple[0][:10])

for i, v in enumerate(test_tuple):
print(f"Testing {i}...")

assert np.allclose(v[: p.T], expected_tuple[i][: p.T])


Expand Down
Loading