Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
27 changes: 23 additions & 4 deletions ogcore/SS.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def euler_equation_solver(guesses, *args):

Args:
guesses (Numpy array): initial guesses for b and n, length 2S
args (tuple): tuple of arguments (r, w, p_tilde, bq, TR, factor, j, p)
args (tuple): tuple of arguments (r, w, p_tilde, p_i, bq, TR, factor, j, p)
r (scalar): real interest rate
w (scalar): real wage rate
p_tilde (scalar): composite good price
Expand All @@ -54,7 +54,7 @@ def euler_equation_solver(guesses, *args):
errros (Numpy array): errors from FOCs, length 2S

"""
(r, w, p_tilde, bq, rm, tr, ubi, factor, j, p) = args
(r, w, p_tilde, p_i, bq, rm, tr, ubi, factor, j, p) = args

b_guess = np.array(guesses[: p.S])
n_guess = np.array(guesses[p.S :])
Expand All @@ -67,6 +67,7 @@ def euler_equation_solver(guesses, *args):
r,
w,
p_tilde,
p_i,
b_s,
b_splus1,
n_guess,
Expand All @@ -88,6 +89,7 @@ def euler_equation_solver(guesses, *args):
r,
w,
p_tilde,
p_i,
b_s,
b_splus1,
n_guess,
Expand Down Expand Up @@ -143,13 +145,15 @@ def euler_equation_solver(guesses, *args):
r,
w,
p_tilde,
p_i,
b_s,
b_splus1,
n_guess,
bq,
rm,
taxes,
p.e[-1, :, j],
p.tau_c[-1, :],
p,
)
mask6 = cons < 0
Expand All @@ -164,6 +168,7 @@ def solve_for_j(
r_p,
w,
p_tilde,
p_i,
bq_j,
rm_j,
tr_j,
Expand All @@ -180,6 +185,7 @@ def solve_for_j(
r_p (scalar): return on household investment portfolio
w (scalar): real wage rate
p_tilde (scalar): composite good price
p_i (Numpy array): prices for consumption good i
bq_j (Numpy array): bequest amounts by age, length S
rm_j (Numpy array): remittance amounts by age, length S
tr_j (Numpy array): government transfer amount by age, length S
Expand All @@ -200,6 +206,7 @@ def solve_for_j(
r_p,
w,
p_tilde,
p_i,
bq_j,
rm_j,
tr_j,
Expand Down Expand Up @@ -314,6 +321,7 @@ def inner_loop(outer_loop_vars, p, client):
r_p,
w,
p_tilde,
p_i,
bq[:, j],
rm[:, j],
tr[:, j],
Expand Down Expand Up @@ -346,6 +354,7 @@ def inner_loop(outer_loop_vars, p, client):
r_p,
w,
p_tilde,
p_i,
bq[:, j],
rm[:, j],
tr[:, j],
Expand All @@ -365,6 +374,7 @@ def inner_loop(outer_loop_vars, p, client):
r_p,
w,
p_tilde,
p_i,
bq[:, j],
rm[:, j],
tr[:, j],
Expand Down Expand Up @@ -416,16 +426,20 @@ def inner_loop(outer_loop_vars, p, client):
r_p,
w,
p_tilde,
p_i,
b_s,
b_splus1,
nssmat,
bq,
rm,
net_tax,
np.squeeze(p.e[-1, :, :]),
p.tau_c[-1, :],
p,
)
c_i = household.get_ci(c_s, p_i, p_tilde, p.tau_c[-1, :], p.alpha_c)
c_i = household.get_ci(
c_s, p_i, p_tilde, p.tau_c[-1, :], p.alpha_c, p.c_min
)
L = aggr.get_L(nssmat, p, "SS")
B = aggr.get_B(bssmat, p, "SS", False)

Expand Down Expand Up @@ -551,13 +565,15 @@ def inner_loop(outer_loop_vars, p, client):
new_r_p,
new_w,
new_p_tilde,
new_p_i,
b_s,
bssmat,
nssmat,
new_bq,
new_rm,
taxss,
np.squeeze(p.e[-1, :, :]),
p.tau_c[-1, :],
p,
)
(
Expand Down Expand Up @@ -990,13 +1006,15 @@ def SS_solver(
r_p_ss,
wss,
p_tilde_ss,
p_i_ss,
bssmat_s,
bssmat_splus1,
nssmat,
bqssmat,
rmssmat,
taxss,
np.squeeze(p.e[-1, :, :]),
p.tau_c[-1, :],
p,
)
c_i = household.get_ci(
Expand All @@ -1005,6 +1023,7 @@ def SS_solver(
p_tilde_ss,
p.tau_c[-1, :],
p.alpha_c,
p.c_min,
"SS",
)
sales_tax_ss = tax.cons_tax_liab(c_i, p_i_ss, p, "SS")
Expand All @@ -1013,7 +1032,7 @@ def SS_solver(
)
Css = aggr.get_C(cssmat, p, "SS")
c_i_ss_mat = household.get_ci(
cssmat, p_i_ss, p_tilde_ss, p.tau_c[-1, :], p.alpha_c
cssmat, p_i_ss, p_tilde_ss, p.tau_c[-1, :], p.alpha_c, p.c_min
)
C_vec_ss = np.zeros(p.I)
for i_ind in range(
Expand Down
32 changes: 31 additions & 1 deletion ogcore/TPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,20 @@ def get_initial_SS_values(p):


def firstdoughnutring(
guesses, r, w, p_tilde, bq, rm, tr, theta, factor, ubi, j, initial_b, p
guesses,
r,
w,
p_tilde,
p_i,
bq,
rm,
tr,
theta,
factor,
ubi,
j,
initial_b,
p,
):
"""
Solves the first entries of the upper triangle of the twist doughnut. This
Expand All @@ -141,6 +154,7 @@ def firstdoughnutring(
r (scalar): real interest rate
w (scalar): real wage rate
p_tilde (scalar): composite good price
p_i (Numpy array): output goods prices
bq (scalar): bequest amounts by age
rm (scalar): remittance amounts by age
tr (scalar): government transfer amount
Expand All @@ -166,6 +180,7 @@ def firstdoughnutring(
np.array([r]),
np.array([w]),
np.array([p_tilde]),
np.array([p_i]),
b_s,
np.array([b_splus1]),
np.array([n]),
Expand All @@ -188,6 +203,7 @@ def firstdoughnutring(
np.array([r]),
np.array([w]),
np.array([p_tilde]),
np.array([p_i]),
b_s,
b_splus1,
np.array([n]),
Expand Down Expand Up @@ -219,6 +235,7 @@ def twist_doughnut(
r,
w,
p_tilde,
p_i,
bq,
rm,
tr,
Expand All @@ -244,6 +261,7 @@ def twist_doughnut(
r (Numpy array): real interest rate
w (Numpy array): real wage rate
p_tilde (Numpy array): composite good price
p_i (Numpy array): output goods prices
bq (Numpy array): bequest amounts by age, length s
rm (Numpy array): remittance amounts by age, length s
tr (Numpy array): government transfer amount
Expand Down Expand Up @@ -281,6 +299,7 @@ def twist_doughnut(
w_s = w[t : t + length]
r_s = r[t : t + length]
p_tilde_s = p_tilde[t : t + length]
p_i_s = p_i[t : t + length, :]
n_s = n_guess
chi_n_s = np.diag(p.chi_n[t : t + p.S, :], max(p.S - length, 0))
rho_s = np.diag(p.rho[t : t + p.S, :], max(p.S - length, 0))
Expand All @@ -289,6 +308,7 @@ def twist_doughnut(
r_s,
w_s,
p_tilde_s,
p_i_s,
b_s,
b_splus1,
n_s,
Expand All @@ -311,6 +331,7 @@ def twist_doughnut(
r_s,
w_s,
p_tilde_s,
p_i_s,
b_s,
b_splus1,
n_s,
Expand Down Expand Up @@ -408,6 +429,7 @@ def inner_loop(guesses, outer_loop_vars, initial_values, ubi, j, ind, p):
r_p[0],
w[0],
p_tilde[0],
p_i[0, :],
bq[0, -1, j],
rm[0, -1, j],
tr[0, -1, j],
Expand Down Expand Up @@ -463,6 +485,7 @@ def inner_loop(guesses, outer_loop_vars, initial_values, ubi, j, ind, p):
r_p,
w,
p_tilde,
p_i,
bq_to_use,
rm_to_use,
tr_to_use,
Expand Down Expand Up @@ -518,6 +541,7 @@ def inner_loop(guesses, outer_loop_vars, initial_values, ubi, j, ind, p):
r_p,
w,
p_tilde,
p_i,
bq_to_use,
rm_to_use,
tr_to_use,
Expand Down Expand Up @@ -916,26 +940,31 @@ def run_TPI(p, client=None):
)
r_p_path = utils.to_timepath_shape(r_p)
p_tilde_path = utils.to_timepath_shape(p_tilde)

wpath = utils.to_timepath_shape(w)
c_mat = household.get_cons(
r_p_path[: p.T, :, :],
wpath[: p.T, :, :],
p_tilde_path[: p.T, :, :],
p_i[: p.T, :],
bmat_s,
bmat_splus1,
n_mat[: p.T, :, :],
bqmat[: p.T, :, :],
rmmat[: p.T, :, :],
tax_mat,
p.e,
p.tau_c[: p.T, :],
p,
method="TPI",
)
c_i = household.get_ci(
c_mat[: p.T, :, :],
p_i[: p.T, :],
p_tilde[: p.T],
p.tau_c[: p.T, :],
p.alpha_c,
p.c_min,
"TPI",
)
sales_tax_mat = tax.cons_tax_liab(c_i, p_i, p, "TPI")
Expand All @@ -947,6 +976,7 @@ def run_TPI(p, client=None):
p_tilde[: p.T],
p.tau_c[: p.T, :],
p.alpha_c,
p.c_min,
"TPI",
)
y_before_tax_mat = household.get_y(
Expand Down
20 changes: 20 additions & 0 deletions ogcore/default_parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,26 @@
}
}
},
"c_min": {
"title": "Minimum consumption levels for each good in the composite consumption good",
"description": "Minimum consumption levels for each good in the composite consumption good.",
"section_1": "Household Parameters",
"section_2": "Behavioral Assumptions",
"notes": "Enter this value in model units.",
"type": "float",
"number_dims": 1,
"value": [
{
"value": [0.0]
}
],
"validators": {
"range": {
"min": 0.0,
"max": 100.0
}
}
},
"gamma": {
"title": "Capital's share of output in firm production function",
"description": "Capital's share of output in firm production function.",
Expand Down
Loading
Loading