Skip to content

Commit f20deb4

Browse files
committed
fix order of r_gv[t]
1 parent e238d83 commit f20deb4

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

ogcore/fiscal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def D_G_path(r, dg_fixed_values, p):
107107
+ agg_pension_outlays[t - 1]
108108
- total_tax_revenue[t - 1]
109109
)
110+
r_gov[t] = get_r_gov(r[t], D[t] / Y[t], p, method="scalar", t=t)
110111
if (t >= p.tG1) and (t < p.tG2):
111112
G[t] = (
112113
growth[t + 1]
@@ -128,7 +129,6 @@ def D_G_path(r, dg_fixed_values, p):
128129
- TR[t]
129130
- UBI_outlays[t]
130131
)
131-
r_gov[t] = get_r_gov(r[t], D[t] / Y[t], p, method="scalar", t=t)
132132
t += 1
133133

134134
# in final period, growth rate has stabilized, so we can replace
@@ -143,6 +143,7 @@ def D_G_path(r, dg_fixed_values, p):
143143
+ agg_pension_outlays[t - 1]
144144
- total_tax_revenue[t - 1]
145145
)
146+
r_gov[t] = get_r_gov(r[t], D[t] / Y[t], p, method="scalar", t=t)
146147
G[t] = (
147148
growth[t] * (p.debt_ratio_ss * Y[t])
148149
- (1 + r_gov[t]) * D[t]
@@ -161,8 +162,7 @@ def D_G_path(r, dg_fixed_values, p):
161162
+ agg_pension_outlays[t]
162163
- total_tax_revenue[t]
163164
)
164-
# find r_gov for last two periods
165-
r_gov[t] = get_r_gov(r[t], D[t] / Y[t], p, method="scalar", t=t)
165+
# find r_gov for the period
166166
r_gov[t+1] = get_r_gov(r[t+1], D[t+1] / Y[t+1], p, method="scalar", t=t+1)
167167
D_ratio_max = np.amax(D[: p.T] / Y[: p.T])
168168
print("Maximum debt ratio: ", D_ratio_max)

tests/test_fiscal.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
D_f1 = df["D_f1"].values
2828
D_f2 = df["D_f2"].values
2929
D_f3 = df["D_f3"].values
30-
r_gov1 = np.ones_like(df["D1"].values) * 0.03 - 0.02 # 0.02 is the default r_gov_shift parameter and the default scale parameter is 1.0, meaning r_gov1 = 0.03 - 0.02 = 0.01
30+
r_gov1 = np.ones_like(df["D1"].values) * 0.05 - 0.02 # 0.02 is the default r_gov_shift parameter and the default scale parameter is 1.0, meaning r_gov1 = 0.05 - 0.02 = 0.03
3131
r_gov2 = r_gov1
3232
r_gov3 = r_gov1
3333
nb1 = df["new_borrow1"].values
@@ -81,7 +81,7 @@ def test_D_G_path(
8181
"budget_balance": budget_balance,
8282
}
8383
p.update_specifications(new_param_values, raise_errors=False)
84-
r = np.ones(p.T + p.S) * 0.03
84+
r = np.ones(p.T + p.S) * 0.05
8585
p.g_n = np.ones(p.T + p.S) * 0.02
8686
D0_baseline = 0.59
8787
Gbaseline[0] = 0.05
@@ -275,7 +275,12 @@ def test_get_TR(
275275
ids=["Scale only", "Scale and shift", "r_gov < 0", "TPI"],
276276
)
277277
def test_get_r_gov(r, p, method, r_gov_expected):
278-
r_gov = fiscal.get_r_gov(r, 0, p, method)
278+
# if r is scalar
279+
if method == "SS":
280+
DY_ratio = 0.0
281+
else:
282+
DY_ratio = np.zeros_like(r)
283+
r_gov = fiscal.get_r_gov(r, DY_ratio, p, method)
279284
assert np.allclose(r_gov, r_gov_expected)
280285

281286

0 commit comments

Comments
 (0)