Skip to content

Commit ff44dbb

Browse files
committed
Merge remote-tracking branch 'upstream/master' into demog
2 parents fc30f99 + 4b894bd commit ff44dbb

17 files changed

+207
-87
lines changed

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: ogcore-dev
22
channels:
33
- conda-forge
44
dependencies:
5-
- python>=3.7.7
5+
- python>=3.7.7, <3.12
66
- ipython
77
- setuptools
88
- scipy>=1.7.1

ogcore/SS.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def euler_equation_solver(guesses, *args):
7878
tr,
7979
ubi,
8080
theta,
81-
p.e[:, j],
8281
p.rho[-1, :],
8382
p.etr_params[-1],
8483
p.mtry_params[-1],
@@ -100,7 +99,6 @@ def euler_equation_solver(guesses, *args):
10099
ubi,
101100
theta,
102101
p.chi_n,
103-
p.e[:, j],
104102
p.etr_params[-1],
105103
p.mtrx_params[-1],
106104
None,
@@ -138,7 +136,7 @@ def euler_equation_solver(guesses, *args):
138136
j,
139137
False,
140138
"SS",
141-
p.e[:, j],
139+
p.e[-1, :, j],
142140
p.etr_params[-1],
143141
p,
144142
)
@@ -151,7 +149,7 @@ def euler_equation_solver(guesses, *args):
151149
n_guess,
152150
bq,
153151
taxes,
154-
p.e[:, j],
152+
p.e[-1, :, j],
155153
p,
156154
)
157155
mask6 = cons < 0
@@ -293,7 +291,7 @@ def inner_loop(outer_loop_vars, p, client):
293291
None,
294292
False,
295293
"SS",
296-
p.e,
294+
np.squeeze(p.e[-1, :, :]),
297295
etr_params_3D,
298296
p,
299297
)
@@ -306,7 +304,7 @@ def inner_loop(outer_loop_vars, p, client):
306304
nssmat,
307305
bq,
308306
net_tax,
309-
p.e,
307+
np.squeeze(p.e[-1, :, :]),
310308
p,
311309
)
312310
c_i = household.get_ci(c_s, p_i, p_tilde, p.tau_c[-1, :], p.alpha_c)
@@ -383,7 +381,7 @@ def inner_loop(outer_loop_vars, p, client):
383381
new_r, new_r_gov, p_m, K_vec, K_g, D, MPKg_vec, p, "SS"
384382
)
385383
average_income_model = (
386-
(new_r_p * b_s + new_w * p.e * nssmat)
384+
(new_r_p * b_s + new_w * np.squeeze(p.e[-1, :, :]) * nssmat)
387385
* p.omega_SS.reshape(p.S, 1)
388386
* p.lambdas.reshape(1, p.J)
389387
).sum()
@@ -425,7 +423,7 @@ def inner_loop(outer_loop_vars, p, client):
425423
None,
426424
False,
427425
"SS",
428-
p.e,
426+
np.squeeze(p.e[-1, :, :]),
429427
etr_params_3D,
430428
p,
431429
)
@@ -438,7 +436,7 @@ def inner_loop(outer_loop_vars, p, client):
438436
nssmat,
439437
new_bq,
440438
taxss,
441-
p.e,
439+
np.squeeze(p.e[-1, :, :]),
442440
p,
443441
)
444442
(
@@ -467,6 +465,7 @@ def inner_loop(outer_loop_vars, p, client):
467465
ubi,
468466
theta,
469467
etr_params_3D,
468+
np.squeeze(p.e[-1, :, :]),
470469
p,
471470
None,
472471
"SS",
@@ -482,6 +481,9 @@ def inner_loop(outer_loop_vars, p, client):
482481
debt_service,
483482
p,
484483
)
484+
print("Agg tax = ", total_tax_revenue)
485+
print("Agg pension outlays = ", agg_pension_outlays)
486+
print("Agg UBI outlays = ", UBI_outlays)
485487
new_TR = fiscal.get_TR(
486488
Y,
487489
TR,
@@ -757,7 +759,7 @@ def SS_solver(
757759
nssmat,
758760
factor,
759761
True,
760-
p.e,
762+
np.squeeze(p.e[-1, :, :]),
761763
etr_params_3D,
762764
mtry_params_3D,
763765
capital_noncompliance_rate_2D,
@@ -770,7 +772,7 @@ def SS_solver(
770772
nssmat,
771773
factor,
772774
False,
773-
p.e,
775+
np.squeeze(p.e[-1, :, :]),
774776
etr_params_3D,
775777
mtrx_params_3D,
776778
labor_noncompliance_rate_2D,
@@ -782,7 +784,7 @@ def SS_solver(
782784
bssmat_s,
783785
nssmat,
784786
factor,
785-
p.e,
787+
np.squeeze(p.e[-1, :, :]),
786788
etr_params_3D,
787789
labor_noncompliance_rate_2D,
788790
capital_noncompliance_rate_2D,
@@ -803,7 +805,7 @@ def SS_solver(
803805
None,
804806
False,
805807
"SS",
806-
p.e,
808+
np.squeeze(p.e[-1, :, :]),
807809
etr_params_3D,
808810
p,
809811
)
@@ -816,10 +818,12 @@ def SS_solver(
816818
nssmat,
817819
bqssmat,
818820
taxss,
819-
p.e,
821+
np.squeeze(p.e[-1, :, :]),
820822
p,
821823
)
822-
yss_before_tax_mat = household.get_y(r_p_ss, wss, bssmat_s, nssmat, p)
824+
yss_before_tax_mat = household.get_y(
825+
r_p_ss, wss, bssmat_s, nssmat, p, "SS"
826+
)
823827
Css = aggr.get_C(cssmat, p, "SS")
824828
c_i_ss_mat = household.get_ci(
825829
cssmat, p_i_ss, p_tilde_ss, p.tau_c[-1, :], p.alpha_c
@@ -860,6 +864,7 @@ def SS_solver(
860864
ubissmat,
861865
theta,
862866
etr_params_3D,
867+
np.squeeze(p.e[-1, :, :]),
863868
p,
864869
None,
865870
"SS",

ogcore/TPI.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ def firstdoughnutring(
154154
np.array([tr]),
155155
np.array([ubi]),
156156
theta[j],
157-
p.e[-1, j],
158157
p.rho[0, -1],
159158
p.etr_params[0][-1],
160159
p.mtry_params[0][-1],
@@ -177,7 +176,6 @@ def firstdoughnutring(
177176
np.array([ubi]),
178177
theta[j],
179178
p.chi_n[-1],
180-
p.e[-1, j],
181179
p.etr_params[0][-1],
182180
p.mtrx_params[0][-1],
183181
None,
@@ -261,7 +259,6 @@ def twist_doughnut(
261259
p_tilde_s = p_tilde[t : t + length]
262260
n_s = n_guess
263261
chi_n_s = p.chi_n[-length:]
264-
e_s = p.e[-length:, j]
265262
rho_s = np.diag(p.rho[t : t + p.S, :], max(p.S - length, 0))
266263

267264
error1 = household.FOC_savings(
@@ -276,7 +273,6 @@ def twist_doughnut(
276273
tr,
277274
ubi,
278275
theta,
279-
e_s,
280276
rho_s,
281277
etr_params,
282278
mtry_params,
@@ -299,7 +295,6 @@ def twist_doughnut(
299295
ubi,
300296
theta,
301297
chi_n_s,
302-
e_s,
303298
etr_params,
304299
mtrx_params,
305300
t,
@@ -823,6 +818,7 @@ def run_TPI(p, client=None):
823818
bmat_s[: p.T, :, :],
824819
n_mat[: p.T, :, :],
825820
p,
821+
"TPI",
826822
)
827823

828824
L[: p.T] = aggr.get_L(n_mat[: p.T], p, "TPI")
@@ -908,6 +904,7 @@ def run_TPI(p, client=None):
908904
ubi[: p.T, :, :],
909905
theta,
910906
etr_params_4D,
907+
p.e,
911908
p,
912909
None,
913910
"TPI",
@@ -1014,6 +1011,7 @@ def run_TPI(p, client=None):
10141011
ubi[: p.T, :, :],
10151012
theta,
10161013
etr_params_4D,
1014+
p.e,
10171015
p,
10181016
None,
10191017
"TPI",
@@ -1143,7 +1141,7 @@ def run_TPI(p, client=None):
11431141
),
11441142
(1, p.S, 1),
11451143
)
1146-
e_3D = np.tile(p.e.reshape(1, p.S, p.J), (p.T, 1, 1))
1144+
e_3D = p.e
11471145
mtry_path = tax.MTR_income(
11481146
r_p_path[: p.T],
11491147
wpath[: p.T],

ogcore/aggregates.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ def get_L(n, p, method):
3333
3434
"""
3535
if method == "SS":
36-
L_presum = p.e * np.transpose(p.omega_SS * p.lambdas) * n
36+
L_presum = (
37+
np.squeeze(p.e[-1, :, :])
38+
* np.transpose(p.omega_SS * p.lambdas)
39+
* n
40+
)
3741
L = L_presum.sum()
3842
elif method == "TPI":
3943
L_presum = (n * (p.e * np.squeeze(p.lambdas))) * np.tile(
@@ -284,6 +288,7 @@ def revenue(
284288
ubi,
285289
theta,
286290
etr_params,
291+
e,
287292
p,
288293
m,
289294
method,
@@ -317,6 +322,7 @@ def revenue(
317322
lifetime income group
318323
etr_params (list): list of parameters of the effective tax rate
319324
functions
325+
e (Numpy array): effective labor units
320326
p (OG-Core Specifications object): model parameters
321327
method (str): adjusts calculation dimensions based on 'SS' or
322328
'TPI'
@@ -339,10 +345,10 @@ def revenue(
339345
340346
"""
341347
inc_pay_tax_liab = tax.income_tax_liab(
342-
r, w, b, n, factor, 0, None, method, p.e, etr_params, p
348+
r, w, b, n, factor, 0, None, method, e, etr_params, p
343349
)
344350
pension_benefits = tax.pension_amount(
345-
w, n, theta, 0, None, False, method, p.e, p
351+
w, n, theta, 0, None, False, method, e, p
346352
)
347353
bq_tax_liab = tax.bequest_tax_liab(r, b, bq, 0, None, method, p)
348354
w_tax_liab = tax.wealth_tax_liab(r, b, 0, None, method, p)

0 commit comments

Comments
 (0)