Skip to content

Commit

Permalink
CES to SS
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason DeBacker committed Mar 22, 2017
1 parent c02c194 commit 62bf77b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Python/ogusa/SS.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def inner_loop(outer_loop_vars, params, baseline):
else:
K = B - debt_ratio_ss*Y
else:
K_params = (alpha, delta, Z)
K_params = (Z, gamma, epsilon, delta)
K = firm.get_K(L, ss_firm_r, K_params)
# Y_params = (alpha, Z)
Y_params = (Z, gamma, epsilon)
Expand Down Expand Up @@ -542,7 +542,7 @@ def SS_solver(b_guess_init, n_guess_init, rss, wss, T_Hss, factor_ss, params, ba
Iss = firm.get_I(bssmat_splus1, Kss, Kss, Iss_params)
else:
# Compute capital (K) and wealth (B) separately
Kss_params = (alpha, delta, Z)
Kss_params = (Z, gamma, epsilon, delta)
Kss = firm.get_K(Lss, ss_firm_r, Kss_params)
Iss_params = (delta, g_y, omega_SS, lambdas, imm_rates, g_n_ss, 'SS')
InvestmentPlaceholder = np.zeros(bssmat_splus1.shape)
Expand Down Expand Up @@ -735,7 +735,7 @@ def SS_fsolve(guesses, params):


# Check and punish violations
if r <= 0:
if r+delta <= 0:
error1 = 1e9
#if r > 1:
# error1 += 1e9
Expand Down
16 changes: 12 additions & 4 deletions Python/ogusa/firm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def get_r(Y, K, params):
r = gamma - delta
else:
r = ((Z**((epsilon-1)/epsilon))*(((gamma*Y)/K)**(1/epsilon))) - delta
print 'r, r+delta = ', r, r+delta


return r


Expand Down Expand Up @@ -198,7 +197,16 @@ def get_K(L, r, params):
Returns: r
'''

alpha, delta , Z = params
Z, gamma, epsilon, delta = params
print 'USING firm.getK()'
if epsilon == 1:
K = (gamma*Z/(r+delta))**(1/(1-gamma)) * L
elif epsilon == 0:
K = (1-((1-gamma)*L))/gamma
else:
K = (((1-gamma)**(1/(epsilon-1)))*(((((r+delta)**(epsilon-1))*(gamma**((1-epsilon)/epsilon))
*(Z**(1-epsilon)))-(gamma**(1/epsilon)))**(epsilon/(1-epsilon)))*L)

print 'USING firm.getK()'
K = (alpha*Z/(r+delta))**(1/(1-alpha)) * L

return K
22 changes: 11 additions & 11 deletions Python/ogusa/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ def get_parameters(test=False, baseline=False, guid='', user_modifiable=False, m
sigma = 1.5 # value from Attanasio, Banks, Meghir and Weber (JEBS, 1999)
alpha = .35 # many use 0.33, but many find that capitals share is increasing (e.g. Elsby, Hobijn, and Sahin (BPEA, 2013))
gamma = 0.35
epsilon = 0.9#0.6
epsilon = 0.6
Z = 1.0
delta_annual = 0.02#.05 # approximately the value from Kehoe calibration exercise: http://www.econ.umn.edu/~tkehoe/classes/calibration-04.pdf
delta_annual = 0.05 # approximately the value from Kehoe calibration exercise: http://www.econ.umn.edu/~tkehoe/classes/calibration-04.pdf
delta = 1 - ((1 - delta_annual) ** (float(ending_age - starting_age) / S))
ltilde = 1.0
g_y_annual = 0.03
Expand Down Expand Up @@ -460,15 +460,15 @@ def get_parameters(test=False, baseline=False, guid='', user_modifiable=False, m


## To shut off demographics, uncomment the following 9 lines of code
g_n_ss = 0.0
surv_rate1 = np.ones((S,))# prob start at age S
surv_rate1[1:] = np.cumprod(surv_rate[:-1], dtype=float)
omega_SS = np.ones(S)*surv_rate1# number of each age alive at any time
omega_SS = omega_SS/omega_SS.sum()
imm_rates = np.zeros((T+S,S))
omega = np.tile(np.reshape(omega_SS,(1,S)),(T+S,1))
omega_S_preTP = omega_SS
g_n_vector = np.tile(g_n_ss,(T+S,))
# g_n_ss = 0.0
# surv_rate1 = np.ones((S,))# prob start at age S
# surv_rate1[1:] = np.cumprod(surv_rate[:-1], dtype=float)
# omega_SS = np.ones(S)*surv_rate1# number of each age alive at any time
# omega_SS = omega_SS/omega_SS.sum()
# imm_rates = np.zeros((T+S,S))
# omega = np.tile(np.reshape(omega_SS,(1,S)),(T+S,1))
# omega_S_preTP = omega_SS
# g_n_vector = np.tile(g_n_ss,(T+S,))

e = inc.get_e_interp(S, omega_SS, omega_SS_80, lambdas, plot=False)
# e_hetero = get_e(S, J, starting_age, ending_age, lambdas, omega_SS, flag_graphs)
Expand Down

0 comments on commit 62bf77b

Please sign in to comment.