Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
38da076
add capital adj cost functions
jdebacker Apr 18, 2019
14f738e
add adj costs parameters to default params
jdebacker Apr 18, 2019
5765070
move assignement of mu to parameters.py
jdebacker Apr 22, 2019
51405d9
make stationarized versions of adjustment cost functions
jdebacker Apr 22, 2019
95b25d1
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker May 1, 2019
d1e3dee
add test of adj cost function
jdebacker May 2, 2019
9455cca
make adj cost derivatives more clear
jdebacker May 2, 2019
3a46039
add tests for adj cost deriv functions
jdebacker May 2, 2019
e9d2339
fix typo in adj cost deriv
jdebacker May 2, 2019
960e392
add second test of adjust cost functions
jdebacker May 2, 2019
839ed74
test adj cost funcs over time path
jdebacker May 3, 2019
3048d5c
add MPK and MPL functions
jdebacker May 10, 2019
08ecd3a
get_r func
jdebacker May 10, 2019
a1e3656
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker May 13, 2019
3be9d45
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Jul 26, 2019
48c83d1
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Aug 4, 2019
44941c2
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Sep 4, 2019
81bd2c6
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Sep 12, 2019
aa49a8b
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Oct 16, 2019
0a0f4f1
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Nov 6, 2019
680efc2
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Nov 13, 2019
81f34ce
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Dec 10, 2019
68e1222
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Dec 27, 2019
680eb8a
merge in master
jdebacker Apr 4, 2020
320931e
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Apr 10, 2020
2104f2c
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker May 6, 2020
e9f8f8d
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker May 13, 2020
69eec46
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Jun 17, 2020
eef0785
add function to compute NPV of depr deductions
jdebacker Jun 18, 2020
2b671fd
test of SS NPV calc
jdebacker Jun 18, 2020
fe98ec4
follow updated param schema
jdebacker Jun 18, 2020
1594a5c
update param values, expected NPV
jdebacker Jun 18, 2020
4034c60
add function to compute law of motion of tax basis for capital stock,…
jdebacker Jun 18, 2020
2baab53
add functions to solve for firm capital demand
jdebacker Jun 18, 2020
999d9af
add function to compute dep val on old capital and test
jdebacker Jun 18, 2020
47ad616
add function to compute q and test it
jdebacker Jun 18, 2020
a9c005a
change notation
jdebacker Jun 19, 2020
ac4202a
test of firm.FOC_I, real exp string
jdebacker Jun 21, 2020
10f7f42
remove unused imports
jdebacker Jun 22, 2020
d39c540
update get_r to include dynamic version
jdebacker Jun 22, 2020
9c412a1
update NPV of depr function and test
jdebacker Jun 22, 2020
6e1a56a
test NPV depr function for constant params
jdebacker Jun 23, 2020
a0ee40a
update npv depr function for non-constant tax params, test it
jdebacker Jun 26, 2020
2cc5926
fix get_I calcs
jdebacker Jul 2, 2020
4c9a490
separate gross and net investment functions
jdebacker Jul 3, 2020
d16606b
use new invest funcs when called
jdebacker Jul 3, 2020
a3184a8
update firm.get_r tests and function for dyn firms
jdebacker Jul 3, 2020
3d69a43
add test for get Y from K
jdebacker Jul 3, 2020
f1d908f
add tests for get_K_demand
jdebacker Jul 4, 2020
e2729c6
update eqn for K_tau law of motion for stationarization
jdebacker Jul 7, 2020
b4d8a96
save at in progress of testing/stationarizing
jdebacker Jul 7, 2020
8f34b05
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Jul 26, 2020
01c1e0d
update tests of get_K_demand for all cases
jdebacker Jul 27, 2020
961c22d
begin refactoring SS algo
jdebacker Jul 27, 2020
6338f5f
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Jul 31, 2020
f345df8
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Aug 6, 2020
8be70ee
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Aug 16, 2020
31ae7dc
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Aug 19, 2020
d5a0a69
temp commit
jdebacker Aug 19, 2020
20bf853
temp commit
jdebacker Aug 19, 2020
854f14e
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Aug 20, 2020
08d934e
temp commit
jdebacker Aug 20, 2020
aba4ccd
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Aug 20, 2020
ae8787e
passing inner loop test
jdebacker Aug 20, 2020
49f60c5
clean up test
jdebacker Aug 21, 2020
bc89388
update SS_solver to pass tests for closed econ with delta tau =0
jdebacker Aug 25, 2020
cd68c61
del keys not in new dict
jdebacker Aug 25, 2020
a706d41
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Oct 5, 2020
7e4df8f
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Oct 16, 2020
986fa38
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Oct 29, 2020
6855b25
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Nov 4, 2020
2686ba7
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Nov 23, 2020
88cf03d
save more vars to output dict
jdebacker Nov 24, 2020
43771ee
begin update tpi for dyn firm
jdebacker Nov 24, 2020
71c2894
fix indexes
jdebacker Nov 25, 2020
3e5a763
more fixes to try to get Tpi working
jdebacker Nov 26, 2020
1af1cfe
temp commits
jdebacker Dec 3, 2020
5d7fce3
Merge remote-tracking branch 'upstream/master' into dyn_firm
jdebacker Dec 17, 2020
d8c38b9
temp commit
jdebacker Dec 20, 2020
769932d
make delta_tau=0 closed econ test
jdebacker Dec 20, 2020
9cbb7e6
merge in master and fix conflict
jdebacker Jan 31, 2021
09bf7ac
placeholder
jdebacker Feb 4, 2021
16d6a4c
update delta tau=0 test to use closed economy
jdebacker Feb 5, 2021
f91d455
Merge branch 'new_test_delta0' into dyn_firm
jdebacker Feb 5, 2021
0386723
sync with master
jdebacker Mar 25, 2021
c19283f
save more objects for testing
jdebacker Mar 26, 2021
9c8dfe5
merge in upstream/master
jdebacker Jul 20, 2021
6b2eaf9
fix conflicts
jdebacker Aug 13, 2021
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
62 changes: 48 additions & 14 deletions ogcore/SS.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,31 @@ def inner_loop(outer_loop_vars, p, client):

L = aggr.get_L(nssmat, p, 'SS')
B = aggr.get_B(bssmat, p, 'SS', False)
K_demand_open = firm.get_K(L, p.world_int_rate[-1], p, 'SS')
K, K_d, K_f = aggr.get_K_splits(B, K_demand_open, D_d, p.zeta_K[-1])
z = firm.get_NPV_depr(r, p, 'SS')
V_d = B - D_d
if np.any(V_d < 0):
print('V_d has negative elements. Setting them ' +
'positive to prevent NAN.')
V_d = np.fmax(V_d, 0.05 * B)
V_f = p.zeta_K[-1] * V_d # So that foreign equity holdings are some fraction of domestic holdings...
# this deviates from CBO method, but theirs doesn't work with dyn firms
# could also try to build in realistic repsonse to world and domestic rates - which CBO doesn't have
V = V_d + V_f
print("V values = ", V, V_d, V_f)
K, K_tau = firm.get_K_demand(None, V, None, z, p, 'SS')
print('K values = ', K, K_tau)

# K_demand_open = firm.get_K(L, p.world_int_rate[-1], p, 'SS')
# K, K_d, K_f = aggr.get_K_splits(B, K_demand_open, D_d, p.zeta_K[-1])
Y = firm.get_Y(K, L, p, 'SS')
X = firm.get_X(z, K_tau)
if p.zeta_K[-1] == 1.0:
new_r = p.world_int_rate[-1]
else:
new_r = firm.get_r(Y, K, p, 'SS')
new_w = firm.get_w_from_r(new_r, p, 'SS')
# new_r = firm.get_r(Y, K, p, 'SS')
new_r = firm.get_r(Y, K, K, V, V, X, X, p, 'SS')
# new_w = firm.get_w_from_r(new_r, p, 'SS')
new_w = firm.get_w(Y, L, p, 'SS')

b_s = np.array(list(np.zeros(p.J).reshape(1, p.J)) +
list(bssmat[:-1, :]))
Expand Down Expand Up @@ -325,15 +342,26 @@ def SS_solver(bmat, nmat, r, BQ, TR, factor, Y, p, client,
Bss = aggr.get_B(bssmat_splus1, p, 'SS', False)
(Dss, D_d_ss, D_f_ss, new_borrowing, debt_service,
new_borrowing_f) = fiscal.get_D_ss(r_gov_ss, Y, p)
K_demand_open_ss = firm.get_K(Lss, p.world_int_rate[-1], p, 'SS')
Kss, K_d_ss, K_f_ss = aggr.get_K_splits(
Bss, K_demand_open_ss, D_d_ss, p.zeta_K[-1])
# K_demand_open_ss = firm.get_K(Lss, p.world_int_rate[-1], p, 'SS')
# Kss, K_d_ss, K_f_ss = aggr.get_K_splits(
# Bss, K_demand_open_ss, D_d_ss, p.zeta_K[-1])
zss = firm.get_NPV_depr(rss, p, 'SS')
V_d_ss = Bss - D_d_ss
if np.any(V_d_ss < 0):
print('V_d_ss has negative elements. Setting them ' +
'positive to prevent NAN.')
V_d_ss = np.fmax(V_d_ss, 0.05 * Bss)
V_f_ss = p.zeta_K[-1] * V_d_ss # So that foreign equity holdings are some fraction of domestic holdings...
# this deviates from CBO method, but theirs doesn't work with dyn firms
# could also try to build in realistic repsonse to world and domestic rates - which CBO doesn't have
Vss = V_d_ss + V_f_ss
Kss, K_tau_ss = firm.get_K_demand(None, Vss, None, zss, p, 'SS')
Yss = firm.get_Y(Kss, Lss, p, 'SS')
r_hh_ss = aggr.get_r_hh(rss, r_gov_ss, Kss, Dss)
# Note that implicity in this computation is that immigrants'
# wealth is all in the form of private capital
I_d_ss = aggr.get_I(bssmat_splus1, K_d_ss, K_d_ss, p, 'SS')
Iss = aggr.get_I(bssmat_splus1, Kss, Kss, p, 'SS')
# I_d_ss = aggr.get_net_I(bssmat_splus1, K_d_ss, K_d_ss, p, 'SS')
Iss = aggr.get_net_I(bssmat_splus1, Kss, Kss, p, 'SS')
wss = new_w
BQss = new_BQ
factor_ss = factor
Expand Down Expand Up @@ -379,10 +407,14 @@ def SS_solver(bmat, nmat, r, BQ, TR, factor, Y, p, client,
new_borrowing, debt_service, p)

# Compute total investment (not just domestic)
Iss_total = aggr.get_I(None, Kss, Kss, p, 'total_ss')
Iss_total = aggr.get_I(Kss, Kss, p.g_n_ss, p.g_y, p.delta)

# solve resource constraint
# net foreign borrowing
K_f_ss = 0 ## temporarily - will come back to open economy case
I_d_ss = Iss
print('Foreign debt holdings = ', D_f_ss)
print('Foreign capital holdings = ', K_f_ss)
debt_service_f = fiscal.get_debt_service_f(r_hh_ss, D_f_ss)
RC = aggr.resource_constraint(
Yss, Css, Gss, I_d_ss, K_f_ss, new_borrowing_f, debt_service_f,
Expand Down Expand Up @@ -414,13 +446,15 @@ def SS_solver(bmat, nmat, r, BQ, TR, factor, Y, p, client,
np.absolute(euler_savings).max())

# Return dictionary of SS results
output = {'Kss': Kss, 'K_f_ss': K_f_ss, 'K_d_ss': K_d_ss,
output = {'Kss': Kss, 'K_tau_ss': K_tau_ss, 'Vss': Vss,
'V_f_ss': V_f_ss, 'V_d_ss': V_d_ss,
'Bss': Bss, 'Lss': Lss, 'Css': Css, 'Iss': Iss,
'Iss_total': Iss_total, 'I_d_ss': I_d_ss, 'nssmat': nssmat,
'Iss_total': Iss_total, 'nssmat': nssmat,
'Yss': Yss, 'Dss': Dss, 'D_f_ss': D_f_ss,
'D_d_ss': D_d_ss, 'wss': wss, 'rss': rss,
'total_taxes_ss': taxss, 'ubissmat': ubissmat,
'r_gov_ss': r_gov_ss, 'r_hh_ss': r_hh_ss, 'theta': theta,
'r_gov_ss': r_gov_ss, 'r_hh_ss': r_hh_ss, 'zss': zss,
'theta': theta, 'total_taxes_ss': taxss,
'ubissmat': ubissmat,
'BQss': BQss, 'factor_ss': factor_ss, 'bssmat_s': bssmat_s,
'cssmat': cssmat, 'bssmat_splus1': bssmat_splus1,
'yss_before_tax_mat': yss_before_tax_mat,
Expand Down
90 changes: 65 additions & 25 deletions ogcore/TPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def get_initial_SS_values(p):
# placeholder for first-period wealth
B0 = aggr.get_B(initial_b, p, 'SS', True)

# Get initial value of the capital stock and initial value of the
# depreciable basis for the capital stock
K0 = ss_baseline_vars['Kss']
K_tau0 = ss_baseline_vars['K_tau_ss']

b_sinit = np.array(list(np.zeros(p.J).reshape(1, p.J)) +
list(initial_b[:-1]))
b_splus1init = initial_b
Expand All @@ -93,7 +98,7 @@ def get_initial_SS_values(p):
else:
D0_baseline = None

initial_values = (B0, b_sinit, b_splus1init, factor, initial_b,
initial_values = (B0, K0, K_tau0, b_sinit, b_splus1init, factor, initial_b,
initial_n)
baseline_values = (TRbaseline, Gbaseline, D0_baseline)

Expand Down Expand Up @@ -268,7 +273,8 @@ def inner_loop(guesses, outer_loop_vars, initial_values, ubi, j, ind, p):
* n_mat (Numpy array): labor supply amounts, size = TxS

'''
(K0, b_sinit, b_splus1init, factor, initial_b, initial_n) =\
# unpack variables and parameters pass to function
(B0, K0, K_tau0, b_sinit, b_splus1init, factor, initial_b, initial_n) =\
initial_values
guesses_b, guesses_n = guesses
r, w, r_hh, BQ, TR, theta = outer_loop_vars
Expand Down Expand Up @@ -389,8 +395,8 @@ def run_TPI(p, client=None):
'''
# unpack tuples of parameters
initial_values, ss_vars, theta, baseline_values = get_initial_SS_values(p)
(B0, b_sinit, b_splus1init, factor, initial_b, initial_n) =\
initial_values
(B0, K0, K_tau0, b_sinit, b_splus1init, factor, initial_b,
initial_n) = initial_values
(TRbaseline, Gbaseline, D0_baseline) = baseline_values

# Create time path of UBI household benefits and aggregate UBI outlays
Expand All @@ -416,17 +422,27 @@ def run_TPI(p, client=None):
L_init[:p.T] = aggr.get_L(n_mat[:p.T], p, 'TPI')
B_init[1:p.T] = aggr.get_B(b_mat[:p.T], p, 'TPI', False)[:p.T - 1]
B_init[0] = B0
K_init = B_init * ss_vars['Kss'] / ss_vars['Bss']
K = K_init
K_d = K_init * ss_vars['K_d_ss'] / ss_vars['Kss']
K_f = K_init * ss_vars['K_f_ss'] / ss_vars['Kss']
V_init = B_init * ss_vars['Vss'] / ss_vars['Bss']
V = V_init
V_d = V_init * ss_vars['V_d_ss'] / ss_vars['Vss']
V_f = V_init * ss_vars['V_f_ss'] / ss_vars['Vss']
# compute z
z = np.ones(p.T + p.S) * ss_vars['zss']
K = np.ones(p.T + p.S) * ss_vars['Kss']
K_tau = np.ones(p.T + p.S) * ss_vars['K_tau_ss']
K[:p.T], K_tau[:p.T] = firm.get_K_demand(
K0, V[:p.T], K_tau0, z[:p.T], p, 'TPI')
X = firm.get_X(z, K_tau)
L = L_init
B = B_init
Y = np.zeros_like(K)
Y[:p.T] = firm.get_Y(K[:p.T], L[:p.T], p, 'TPI')
Y[p.T:] = ss_vars['Yss']
r = np.zeros_like(Y)
r[:p.T] = firm.get_r(Y[:p.T], K[:p.T], p, 'TPI')
r[:p.T] = firm.get_r(
Y[:p.T], K[:p.T], K[1:p.T+1], V[:p.T], V[1:p.T+1], X[:p.T],
X[1:p.T+1], p, 'TPI')
# r[:p.T] = firm.get_r(Y[:p.T], K[:p.T], p, 'TPI')
r[p.T:] = ss_vars['rss']
# For case where economy is small open econ
r[p.zeta_K == 1] = p.world_int_rate[p.zeta_K == 1]
Expand Down Expand Up @@ -493,7 +509,7 @@ def run_TPI(p, client=None):

r_hh[:p.T] = aggr.get_r_hh(r[:p.T], r_gov[:p.T], K[:p.T],
D[:p.T])

print("INTREST RATES = ", r[:5], r_gov[:5], r_hh[:5])
outer_loop_vars = (r, w, r_hh, BQ, TR, theta)

euler_errors = np.zeros((p.T, 2 * p.S, p.J))
Expand Down Expand Up @@ -555,22 +571,44 @@ def run_TPI(p, client=None):
debt_service, new_borrowing_f) =\
fiscal.D_G_path(r_gov, dg_fixed_values, p)
L[:p.T] = aggr.get_L(n_mat[:p.T], p, 'TPI')
print('Initial B, V, K = ', B[0], V[0], K[0])
B[1:p.T] = aggr.get_B(bmat_splus1[:p.T], p, 'TPI',
False)[:p.T - 1]
K_demand_open = firm.get_K(
L[:p.T], p.world_int_rate[:p.T], p, 'TPI')
K[:p.T], K_d[:p.T], K_f[:p.T] = aggr.get_K_splits(
B[:p.T], K_demand_open, D_d[:p.T], p.zeta_K[:p.T])

z[:p.T] = firm.get_NPV_depr(r, p, 'TPI')[:p.T]
V_d[:p.T] = B[:p.T] - D_d[:p.T]
if np.any(V_d < 0):
print('V_d has negative elements. Setting them ' +
'positive to prevent NAN.')
V_d = np.fmax(V_d, 0.05 * B)
V_f[:p.T] = p.zeta_K[:p.T] * V_d[:p.T] # So that foreign equity holdings are some fraction of domestic holdings...
# this deviates from CBO method, but theirs doesn't work with dyn firms
# could also try to build in realistic repsonse to world and domestic rates - which CBO doesn't have
V[:p.T] = V_d[:p.T] + V_f[:p.T]
X = firm.get_X(z, K_tau)
K0 = V[0] # cheat for now with zero adj costs -- otherwise issue because for some guesses of Y, K0 and V[0] not equal and yield negative interest rate
K[:p.T], K_tau[:p.T] = firm.get_K_demand(K0, V, K_tau0, z, p, 'TPI')

# K_demand_open = firm.get_K(
# L[:p.T], p.world_int_rate[:p.T], p, 'TPI')
# K[:p.T], K_d[:p.T], K_f[:p.T] = aggr.get_K_splits(
# B[:p.T], K_demand_open, D_d[:p.T], p.zeta_K[:p.T])
Ynew = firm.get_Y(K[:p.T], L[:p.T], p, 'TPI')
rnew = r.copy()
rnew[:p.T] = firm.get_r(Ynew[:p.T], K[:p.T], p, 'TPI')
# rnew[:p.T] = firm.get_r(Ynew[:p.T], K[:p.T], p, 'TPI')
rnew[:p.T] = firm.get_r(
Y[:p.T], K[:p.T], K[1:p.T+1], V[:p.T], V[1:p.T+1], X[:p.T],
X[1:p.T+1], p, 'TPI')
print('VARS ALONG THE WAY: ', r[:5], K[:5], Y[:5], V[:5], X[:5])
# For case where economy is small open econ
r[p.zeta_K == 1] = p.world_int_rate[p.zeta_K == 1]
r_gov_new = fiscal.get_r_gov(rnew, p)
r_hh_new = aggr.get_r_hh(rnew[:p.T], r_gov_new[:p.T], K[:p.T],
Dnew[:p.T])
# compute w
wnew = firm.get_w_from_r(rnew[:p.T], p, 'TPI')
# wnew = firm.get_w_from_r(rnew[:p.T], p, 'TPI')
wnew = w
wnew[:p.T] = firm.get_MPL(Ynew[:p.T], L[:p.T], p, 'TPI')

b_mat_shift = np.append(np.reshape(initial_b, (1, p.S, p.J)),
b_mat[:p.T - 1, :, :], axis=0)
Expand All @@ -591,7 +629,8 @@ def run_TPI(p, client=None):
agg_pension_outlays[:p.T], UBI_outlays[:p.T], p, 'TPI')

# update vars for next iteration
w[:p.T] = wnew[:p.T]
# w[:p.T] = wnew[:p.T]
w[:p.T] = utils.convex_combo(wnew[:p.T], w[:p.T], p.nu)
r[:p.T] = utils.convex_combo(rnew[:p.T], r[:p.T], p.nu)
BQ[:p.T] = utils.convex_combo(BQnew[:p.T], BQ[:p.T], p.nu)
D[:p.T] = Dnew[:p.T]
Expand Down Expand Up @@ -665,18 +704,19 @@ def run_TPI(p, client=None):
C = aggr.get_C(c_mat, p, 'TPI')
# Note that implicity in this computation is that immigrants'
# wealth is all in the form of private capital
I_d = aggr.get_I(bmat_splus1[:p.T], K_d[1:p.T + 1], K_d[:p.T], p,
'TPI')
I = aggr.get_I(bmat_splus1[:p.T], K[1:p.T + 1], K[:p.T], p, 'TPI')
# I_d = aggr.get_net_I(
# bmat_splus1[:p.T], K_d[1:p.T + 1], K_d[:p.T], p, 'TPI')
I = aggr.get_net_I(
bmat_splus1[:p.T], K[1:p.T + 1], K[:p.T], p, 'TPI')
# solve resource constraint
# foreign debt service costs
debt_service_f = fiscal.get_debt_service_f(r_hh, D_f)
RC_error = aggr.resource_constraint(
Y[:p.T - 1], C[:p.T - 1], G[:p.T - 1], I_d[:p.T - 1],
K_f[:p.T - 1], new_borrowing_f[:p.T - 1],
Y[:p.T - 1], C[:p.T - 1], G[:p.T - 1], I[:p.T - 1],
V_f[:p.T - 1], new_borrowing_f[:p.T - 1],
debt_service_f[:p.T - 1], r_hh[:p.T - 1], p)
# Compute total investment (not just domestic)
I_total = aggr.get_I(None, K[1:p.T + 1], K[:p.T], p, 'total_tpi')
I_total = aggr.get_net_I(None, K[1:p.T + 1], K[:p.T], p, 'total_tpi')

# Compute resource constraint error
rce_max = np.amax(np.abs(RC_error))
Expand All @@ -699,9 +739,9 @@ def run_TPI(p, client=None):
------------------------------------------------------------------------
'''

output = {'Y': Y[:p.T], 'B': B, 'K': K, 'K_f': K_f, 'K_d': K_d,
output = {'Y': Y[:p.T], 'B': B, 'K': K, 'V_f': V_f, 'V_d': V_d,
'L': L, 'C': C, 'I': I,
'I_total': I_total, 'I_d': I_d, 'BQ': BQ,
'I_total': I_total, 'BQ': BQ,
'total_tax_revenue': total_tax_revenue,
'business_tax_revenue': business_tax_revenue,
'iit_payroll_tax_revenue': iit_payroll_tax_revenue,
Expand Down
28 changes: 26 additions & 2 deletions ogcore/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ def get_L(n, p, method):
return L


def get_I(b_splus1, K_p1, K, p, method):
def get_net_I(b_splus1, K_p1, K, p, method):
r'''
Calculate aggregate investment.
Calculate aggregate investment, accounting for flows from
immigrants.

.. math::
I_{t} = (1 + g_{n,t+1})e^{g_{y}}(K_{t+1} - \sum_{s=E}^{E+S}
Expand Down Expand Up @@ -93,6 +94,29 @@ def get_I(b_splus1, K_p1, K, p, method):
return aggI


def get_I(K_p1, K, g_np1, g_y, delta):
r'''
Calculate gross aggregate investment.

.. math::
I_{t} = (1 + g_{n,t+1})e^{g_{y}}(K_{t+1} - (1 - \delta)K_{t}

Args:
K_p1 (array_like): aggregate capital, one period ahead
K (array_like): aggregate capital
g_np1 (array_like): population growth rate one period ahead
g_y (scalar): growth rate in labor augmenting tech change
delta (scalar): rate of economic depreciation

Returns:
aggI (array_like): aggregate investment

'''
aggI = (1 + g_np1) * np.exp(g_y) * K_p1 - (1.0 - delta) * K

return aggI


def get_B(b, p, method, preTP):
r'''
Calculate aggregate savings
Expand Down
19 changes: 19 additions & 0 deletions ogcore/default_parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,25 @@
}
}
},
"psi": {
"title": "Scale parameter in quadratic capital adjustment cost function",
"description": "Scale parameter in quadratic capital adjustment cost function",
"section_1": "Firm Parameters",
"section_2": "Investment costs",
"notes": "If psi = 0 then the dynamic firm problem collapses to the static firm problem.",
"type": "float",
"value": [
{
"value": 0.0
}
],
"validators": {
"range": {
"min": 0.0,
"max": 10.0
}
}
},
"Z": {
"title": "Total factor productivity in firm production function",
"description": "Total factor productivity in firm production function. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered.",
Expand Down
Loading