From 62bf77baa27b37d8e42224249fd979ed211ec426 Mon Sep 17 00:00:00 2001 From: Jason DeBacker Date: Tue, 21 Mar 2017 20:49:43 -0400 Subject: [PATCH] CES to SS --- Python/ogusa/SS.py | 6 +++--- Python/ogusa/firm.py | 16 ++++++++++++---- Python/ogusa/parameters.py | 22 +++++++++++----------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Python/ogusa/SS.py b/Python/ogusa/SS.py index bbd803c71..49b3b69ac 100644 --- a/Python/ogusa/SS.py +++ b/Python/ogusa/SS.py @@ -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) @@ -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) @@ -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 diff --git a/Python/ogusa/firm.py b/Python/ogusa/firm.py index 2e80d2446..ca47495a7 100644 --- a/Python/ogusa/firm.py +++ b/Python/ogusa/firm.py @@ -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 @@ -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 diff --git a/Python/ogusa/parameters.py b/Python/ogusa/parameters.py index aa83aa469..a832966af 100644 --- a/Python/ogusa/parameters.py +++ b/Python/ogusa/parameters.py @@ -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 @@ -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)