------------------------------------------------------------------------ e = S x J matrix of age dependent possible working abilities e_s omega = T x S x J array of demographics g_n = steady state population growth rate omega_SS = steady state population distribution surv_rate = S x 1 array of survival rates rho = S x 1 array of mortality rates ------------------------------------------------------------------------ ''' if SS_stage == 'first_run_for_guesses': # These values never change, so only run it once omega, g_n, omega_SS, surv_rate = demographics.get_omega( S, J, T, lambdas, starting_age, ending_age, E) e = income.get_e(S, J, starting_age, ending_age, lambdas, omega_SS) rho = 1-surv_rate var_names = ['omega', 'g_n', 'omega_SS', 'surv_rate', 'e', 'rho'] dictionary = {} for key in var_names: dictionary[key] = globals()[key] pickle.dump(dictionary, open("OUTPUT/income_demo_vars.pkl", "w")) else: variables = pickle.load(open("OUTPUT/income_demo_vars.pkl", "r")) for key in variables: globals()[key] = variables[key] chi_n_guess = np.array([47.12000874 , 22.22762421 , 14.34842241 , 10.67954008 , 8.41097278 , 7.15059004 , 6.46771332 , 5.85495452 , 5.46242013 , 5.00364263 , 4.57322063 , 4.53371545 , 4.29828515 , 4.10144524 , 3.8617942 , 3.57282
Generate income and demographic parameters ------------------------------------------------------------------------ e = S x J matrix of age dependent possible working abilities e_s omega = T x S x J array of demographics g_n = steady state population growth rate omega_SS = steady state population distribution children = T x starting_age x J array of children demographics surv_rate = S x 1 array of survival rates mort_rate = S x 1 array of mortality rates ------------------------------------------------------------------------ ''' omega, g_n, omega_SS, children, surv_rate = demographics.get_omega( S, J, T, bin_weights, starting_age, ending_age, E) e = income.get_e(S, J, starting_age, ending_age, bin_weights, omega_SS) mort_rate = 1 - surv_rate surv_rate[-1] = 0.0 mort_rate[-1] = 1 ''' ------------------------------------------------------------------------ Finding the Steady State ------------------------------------------------------------------------ K_guess_init = (S-1 x J) array for the initial guess of the distribution of capital L_guess_init = (S x J) array for the initial guess of the distribution of labor solutions = ((S * (S-1) * J * J) x 1) array of solutions of the steady state distributions of capital and labor Kssmat = ((S-1) x J) array of the steady state distribution of
def get_full_parameters(): # Model Parameters S = 80 J = 7 T = int(2 * S) lambdas = np.array([.25, .25, .2, .1, .1, .09, .01]) starting_age = 20 ending_age = 100 E = int(starting_age * (S / float(ending_age-starting_age))) beta_annual = .96 beta = beta_annual ** (float(ending_age-starting_age) / S) sigma = 3.0 alpha = .35 Z = 1.0 delta_annual = .05 delta = 1 - ((1-delta_annual) ** (float(ending_age-starting_age) / S)) ltilde = 1.0 g_y_annual = 0.03 g_y = (1 + g_y_annual)**(float(ending_age-starting_age)/S) - 1 # Ellipse parameters b_ellipse = 25.6594 k_ellipse = -26.4902 upsilon = 3.0542 # Tax parameters: # Income Tax Parameters mean_income_data = 84377.0 a_tax_income = 3.03452713268985e-06 b_tax_income = .222 c_tax_income = 133261.0 d_tax_income = .219 # Wealth tax params # These are non-calibrated values, h and m just need # need to be nonzero to avoid errors. When p_wealth # is zero, there is no wealth tax. h_wealth = 0.1 m_wealth = 1.0 p_wealth = 0.0 # Bequest and Payroll Taxes tau_bq = np.zeros(J) tau_payroll = 0.15 retire = np.round(9.0 * S / 16.0) - 1 # Simulation Parameters MINIMIZER_TOL = 1e-14 MINIMIZER_OPTIONS = None PLOT_TPI = True maxiter = 250 mindist_SS = 1e-9 mindist_TPI = 1e-6 nu = .4 flag_graphs = False # Calibration parameters # These guesses are close to the calibrated values chi_b_guess = np.array([2, 10, 90, 350, 1700, 22000, 120000]) chi_n_guess = np.array([47.12000874 , 22.22762421 , 14.34842241 , 10.67954008 , 8.41097278 , 7.15059004 , 6.46771332 , 5.85495452 , 5.46242013 , 5.00364263 , 4.57322063 , 4.53371545 , 4.29828515 , 4.10144524 , 3.8617942 , 3.57282 , 3.47473172 , 3.31111347 , 3.04137299 , 2.92616951 , 2.58517969 , 2.48761429 , 2.21744847 , 1.9577682 , 1.66931057 , 1.6878927 , 1.63107201 , 1.63390543 , 1.5901486 , 1.58143606 , 1.58005578 , 1.59073213 , 1.60190899 , 1.60001831 , 1.67763741 , 1.70451784 , 1.85430468 , 1.97291208 , 1.97017228 , 2.25518398 , 2.43969757 , 3.21870602 , 4.18334822 , 4.97772026 , 6.37663164 , 8.65075992 , 9.46944758 , 10.51634777 , 12.13353793 , 11.89186997 , 12.07083882 , 13.2992811 , 14.07987878 , 14.19951571 , 14.97943562 , 16.05601334 , 16.42979341 , 16.91576867 , 17.62775142 , 18.4885405 , 19.10609921 , 20.03988031 , 20.86564363 , 21.73645892 , 22.6208256 , 23.37786072 , 24.38166073 , 25.22395387 , 26.21419653 , 27.05246704 , 27.86896121 , 28.90029708 , 29.83586775 , 30.87563699 , 31.91207845 , 33.07449767 , 34.27919965 , 35.57195873 , 36.95045988 , 38.62308152]) # Generate Income and Demographic parameters omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector = get_omega( S, T, starting_age, ending_age, E, flag_graphs) e = get_e(S, J, starting_age, ending_age, lambdas, omega_SS, flag_graphs) allvars = dict(locals()) return allvars
------------------------------------------------------------------------ e = S x J matrix of age dependent possible working abilities e_s omega = T x S x J array of demographics g_n = steady state population growth rate omega_SS = steady state population distribution children = T x starting_age x J array of children demographics surv_rate = S x 1 array of survival rates mort_rate = S x 1 array of mortality rates ------------------------------------------------------------------------ ''' if SS_stage == 'first_run_for_guesses': omega, g_n, omega_SS, children, surv_rate = demographics.get_omega( S, J, T, bin_weights, starting_age, ending_age, E) e = income.get_e(S, J, starting_age, ending_age, bin_weights, omega_SS) mort_rate = 1-surv_rate var_names = ['omega', 'g_n', 'omega_SS', 'children', 'surv_rate', 'e', 'mort_rate'] dictionary = {} for key in var_names: dictionary[key] = globals()[key] pickle.dump(dictionary, open("OUTPUT/income_demo_vars.pkl", "w")) else: variables = pickle.load(open("OUTPUT/income_demo_vars.pkl", "r")) for key in variables: globals()[key] = variables[key] chi_n_guess = np.array([47.12000874 , 22.22762421 , 14.34842241 , 10.67954008 , 8.41097278 , 7.15059004 , 6.46771332 , 5.85495452 , 5.46242013 , 5.00364263 , 4.57322063 , 4.53371545 , 4.29828515 , 4.10144524 , 3.8617942 , 3.57282
def get_full_parameters(): ''' -------------------------------------------------------------------- Set exogenous model parameters including parameters determined outside the model from other processes -------------------------------------------------------------------- -------------------------------------------------------------------- ''' # Model Parameters S = int(80) J = int(7) T = int(3 * S) lambdas = np.array([.25, .25, .2, .1, .1, .09, .01]) starting_age = int(21) ending_age = int(100) E = int( round( float(S) * (float(starting_age) - 1) / (float(ending_age - starting_age) + 1))) beta_annual = .96 beta = beta_annual**(float(ending_age - starting_age + 1) / S) sigma = 3.0 alpha = .35 Z = 1.0 delta_annual = .05 delta = 1 - ( (1 - delta_annual)**(float(ending_age - starting_age + 1) / S)) ltilde = 1.0 g_y_annual = 0.03 g_y = (1 + g_y_annual)**(float(ending_age - starting_age + 1) / S) - 1 # Elliptical disutility of labor parameters b_ellipse = 25.6594 k_ellipse = -26.4902 upsilon = 3.0542 # Set parameters to generate effective tax rate parameters beg_yr = int(2015) end_yr = int(2024) tpers = int(end_yr - beg_yr + 1) numparams = int(10) desc_data = False graph_data = False graph_est = False dmtrgr_est = False params_txfn = (starting_age, ending_age, beg_yr, end_yr, tpers, numparams, desc_data, graph_data, graph_est, dmtrgr_est) dict_tfparams = txfn.get_TaxFunParams(params_txfn) # Simulation Parameters MINIMIZER_TOL = 1e-14 MINIMIZER_OPTIONS = None PLOT_TPI = True maxiter = 250 mindist_SS = 1e-9 mindist_TPI = 1e-6 nu = .4 flag_graphs = False # Calibration parameters # These guesses are close to the calibrated values chi_b_guess = np.array([2, 10, 90, 350, 1700, 22000, 120000]) chi_n_guess = np.array([ 47.12000874, 22.22762421, 14.34842241, 10.67954008, 8.41097278, 7.15059004, 6.46771332, 5.85495452, 5.46242013, 5.00364263, 4.57322063, 4.53371545, 4.29828515, 4.10144524, 3.8617942, 3.57282, 3.47473172, 3.31111347, 3.04137299, 2.92616951, 2.58517969, 2.48761429, 2.21744847, 1.9577682, 1.66931057, 1.6878927, 1.63107201, 1.63390543, 1.5901486, 1.58143606, 1.58005578, 1.59073213, 1.60190899, 1.60001831, 1.67763741, 1.70451784, 1.85430468, 1.97291208, 1.97017228, 2.25518398, 2.43969757, 3.21870602, 4.18334822, 4.97772026, 6.37663164, 8.65075992, 9.46944758, 10.51634777, 12.13353793, 11.89186997, 12.07083882, 13.2992811, 14.07987878, 14.19951571, 14.97943562, 16.05601334, 16.42979341, 16.91576867, 17.62775142, 18.4885405, 19.10609921, 20.03988031, 20.86564363, 21.73645892, 22.6208256, 23.37786072, 24.38166073, 25.22395387, 26.21419653, 27.05246704, 27.86896121, 28.90029708, 29.83586775, 30.87563699, 31.91207845, 33.07449767, 34.27919965, 35.57195873, 36.95045988, 38.62308152 ]) # Generate Income and Demographic parameters omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector = get_omega( S, T, starting_age, ending_age, E, flag_graphs) e = get_e(S, J, starting_age, ending_age, lambdas, omega_SS, flag_graphs) allvars = dict(locals()) return allvars
def get_full_parameters(baseline, guid, user_modifiable, metadata): ''' -------------------------------------------------------------------- This function sets the parameters for the full model. -------------------------------------------------------------------- INPUTS: baseline = boolean, =True if baseline tax policy, =False if reform guid = string, id for reform run user_modifiable = boolean, =True if allow user modifiable parameters metadata = boolean, =True if use metadata file for parameter values (rather than what is entered in parameters below) OTHER FUNCTIONS AND FILES CALLED BY THIS FUNCTION: read_tax_func_estimate() elliptical_u_est.estimation() read_parameter_metadata() OBJECTS CREATED WITHIN FUNCTION: See parameters defined above allvars = dictionary, dictionary with all parameters defined in this function RETURNS: allvars OUTPUT: None -------------------------------------------------------------------- ''' # Model Parameters S = int(80) J = int(7) T = int(2 * S) BQ_dist = MVKDE(S, J ,proportion_matrix = None, filename = 'BQ_dist.txt', plot = False, bandwidth = .25) BW = int(10) lambdas = np.array([.25, .25, .2, .1, .1, .09, .01]) starting_age = 20 ending_age = 100 E = int(starting_age * (S / float(ending_age - starting_age))) beta_annual = .96 # Carroll (JME, 2009) beta = beta_annual ** (float(ending_age - starting_age) / S) 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)) Z = 1.0 delta_annual = .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 g_y = (1 + g_y_annual)**(float(ending_age - starting_age) / S) - 1 # Ellipse parameters frisch = 0.4 # Frisch elasticity consistent with Altonji (JPE, 1996) and Peterman (Econ Inquiry, 2016) b_ellipse, upsilon = elliptical_u_est.estimation(frisch,ltilde) k_ellipse = 0 # this parameter is just a level shifter in utlitiy - irrelevant for analysis # Tax parameters: # Income Tax Parameters # will call tax function estimation function here... # do output such that each parameters is in a separate SxBW array # read in estimated parameters print 'baselines is:', baseline if baseline: baseline_pckl = "TxFuncEst_baseline{}.pkl".format(guid) estimate_file = os.path.join(TAX_ESTIMATE_PATH, baseline_pckl) print 'using baseline2 tax parameters' dict_params = read_tax_func_estimate(estimate_file, baseline_pckl) else: policy_pckl = "TxFuncEst_policy{}.pkl".format(guid) estimate_file = os.path.join(TAX_ESTIMATE_PATH, policy_pckl) print 'using policy2 tax parameters' dict_params = read_tax_func_estimate(estimate_file, policy_pckl) mean_income_data = dict_params['tfunc_avginc'][0] # etr_params = dict_params['tfunc_etr_params_S'][:S,:BW,:] # mtrx_params = dict_params['tfunc_mtrx_params_S'][:S,:BW,:] # mtry_params = dict_params['tfunc_mtry_params_S'][:S,:BW,:] # set etrs and mtrs to constant rates over income/age etr_params = np.zeros((S,BW,10)) mtrx_params = np.zeros((S,BW,10)) mtry_params = np.zeros((S,BW,10)) etr_params[:,:,7] = dict_params['tfunc_avg_etr'] mtrx_params[:,:,7] = dict_params['tfunc_avg_mtrx'] mtry_params[:,:,7] = dict_params['tfunc_avg_mtry'] etr_params[:,:,9] = dict_params['tfunc_avg_etr'] mtrx_params[:,:,9] = dict_params['tfunc_avg_mtrx'] mtry_params[:,:,9] = dict_params['tfunc_avg_mtry'] etr_params[:,:,5] = 1.0 mtrx_params[:,:,5] = 1.0 mtry_params[:,:,5] = 1.0 # To zero out income taxes, uncomment the following 3 lines: # etr_params[:,:,6:] = 0.0 # mtrx_params[:,:,6:] = 0.0 # mtry_params[:,:,6:] = 0.0 # Wealth tax params # These are non-calibrated values, h and m just need # need to be nonzero to avoid errors. When p_wealth # is zero, there is no wealth tax. h_wealth = 0.1 m_wealth = 1.0 p_wealth = 0.0 # Bequest and Payroll Taxes tau_bq = np.zeros(J) tau_payroll = 0.0 #0.15 # were are inluding payroll taxes in tax functions for now retire = np.round(9.0 * S / 16.0) - 1 # Simulation Parameters MINIMIZER_TOL = 1e-14 MINIMIZER_OPTIONS = None PLOT_TPI = False maxiter = 250 mindist_SS = 1e-9 mindist_TPI = 2e-5 nu = .4 flag_graphs = False # Calibration parameters # These guesses are close to the calibrated values chi_b_guess = np.ones((J,)) * 80.0 #chi_b_guess = np.array([0.7, 0.7, 1.0, 1.2, 1.2, 1.2, 1.4]) #chi_b_guess = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 4.0, 10.0]) #chi_b_guess = np.array([5, 10, 90, 250, 250, 250, 250]) #chi_b_guess = np.array([2, 10, 90, 350, 1700, 22000, 120000]) chi_n_guess = np.array([38.12000874, 33.22762421, 25.34842241, 26.67954008, 24.41097278, 23.15059004, 22.46771332, 21.85495452, 21.46242013, 22.00364263, 21.57322063, 21.53371545, 21.29828515, 21.10144524, 20.8617942, 20.57282, 20.47473172, 20.31111347, 19.04137299, 18.92616951, 20.58517969, 20.48761429, 20.21744847, 19.9577682, 19.66931057, 19.6878927, 19.63107201, 19.63390543, 19.5901486, 19.58143606, 19.58005578, 19.59073213, 19.60190899, 19.60001831, 21.67763741, 21.70451784, 21.85430468, 21.97291208, 21.97017228, 22.25518398, 22.43969757, 23.21870602, 24.18334822, 24.97772026, 26.37663164, 29.65075992, 30.46944758, 31.51634777, 33.13353793, 32.89186997, 38.07083882, 39.2992811, 40.07987878, 35.19951571, 35.97943562, 37.05601334, 37.42979341, 37.91576867, 38.62775142, 39.4885405, 37.10609921, 40.03988031, 40.86564363, 41.73645892, 42.6208256, 43.37786072, 45.38166073, 46.22395387, 50.21419653, 51.05246704, 53.86896121, 53.90029708, 61.83586775, 64.87563699, 66.91207845, 68.07449767, 71.27919965, 73.57195873, 74.95045988, 76.62308152]) # Generate Income and Demographic parameters omega_hat, g_n_ss, omega_SS, surv_rate, rho, g_n_vector = get_omega( S, T, starting_age, ending_age, E, flag_graphs) # omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector = get_pop_objs( # E, S, T, 0, 100, 2015, flag_graphs) # print 'Differences:' # print 'omega diffs: ', (np.absolute(omega-omega2)).max() # print 'g_n', g_n_ss, g_n_ss2 # print 'omega SS diffs: ', (np.absolute(omega_SS-omega_SS2)).max() # print 'surv diffs: ', (np.absolute(surv_rate- surv_rate2)).max() # print 'mort diffs: ', (np.absolute(rho- rho2)).max() # print 'g_n_TP diffs: ', (np.absolute(g_n_vector- g_n_vector2)).max() # quit() #print 'omega_SS shape: ', omega_SS.shape 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() omega = np.tile(np.reshape(omega_SS,(1,S)),(T+S,1)) g_n_vector = np.tile(g_n_ss,(T+S,)) e_hetero = get_e(S, J, starting_age, ending_age, lambdas, omega_SS, flag_graphs) e = np.tile(((e_hetero*lambdas).sum(axis=1)).reshape(S,1),(1,J)) e /= (e * omega_SS.reshape(S, 1)* lambdas.reshape(1, J)).sum() allvars = dict(locals()) if user_modifiable: allvars = {k:allvars[k] for k in USER_MODIFIABLE_PARAMS} if metadata: params_meta = read_parameter_metadata() for k,v in allvars.iteritems(): params_meta[k]["value"] = v allvars = params_meta return allvars
def get_full_parameters(baseline, guid, user_modifiable, metadata): ''' -------------------------------------------------------------------- This function sets the parameters for the full model. -------------------------------------------------------------------- INPUTS: baseline = boolean, =True if baseline tax policy, =False if reform guid = string, id for reform run user_modifiable = boolean, =True if allow user modifiable parameters metadata = boolean, =True if use metadata file for parameter values (rather than what is entered in parameters below) OTHER FUNCTIONS AND FILES CALLED BY THIS FUNCTION: read_tax_func_estimate() elliptical_u_est.estimation() read_parameter_metadata() OBJECTS CREATED WITHIN FUNCTION: See parameters defined above allvars = dictionary, dictionary with all parameters defined in this function RETURNS: allvars OUTPUT: None -------------------------------------------------------------------- ''' # Model Parameters S = int(80) J = int(7) T = int(2 * S) BW = int(10) lambdas = np.array([.25, .25, .2, .1, .1, .09, .01]) starting_age = 20 ending_age = 100 E = int(starting_age * (S / float(ending_age - starting_age))) beta_annual = .96 # Carroll (JME, 2009) beta = beta_annual ** (float(ending_age - starting_age) / S) 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)) Z = 1.0 delta_annual = .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 g_y = (1 + g_y_annual)**(float(ending_age - starting_age) / S) - 1 # Ellipse parameters frisch = 0.4 # Frisch elasticity consistent with Altonji (JPE, 1996) and Peterman (Econ Inquiry, 2016) b_ellipse, upsilon = elliptical_u_est.estimation(frisch,ltilde) k_ellipse = 0 # this parameter is just a level shifter in utlitiy - irrelevant for analysis # Tax parameters: # Income Tax Parameters # will call tax function estimation function here... # do output such that each parameters is in a separate SxBW array # read in estimated parameters print 'baselines is:', baseline if baseline: baseline_pckl = "TxFuncEst_baseline{}.pkl".format(guid) estimate_file = os.path.join(TAX_ESTIMATE_PATH, baseline_pckl) print 'using baseline2 tax parameters' dict_params = read_tax_func_estimate(estimate_file, baseline_pckl) else: policy_pckl = "TxFuncEst_policy{}.pkl".format(guid) estimate_file = os.path.join(TAX_ESTIMATE_PATH, policy_pckl) print 'using policy2 tax parameters' dict_params = read_tax_func_estimate(estimate_file, policy_pckl) mean_income_data = dict_params['tfunc_avginc'][0] # etr_params = dict_params['tfunc_etr_params_S'][:S,:BW,:] # mtrx_params = dict_params['tfunc_mtrx_params_S'][:S,:BW,:] # mtry_params = dict_params['tfunc_mtry_params_S'][:S,:BW,:] # set etrs and mtrs to constant rates over income/age etr_params = np.zeros((S,BW,10)) mtrx_params = np.zeros((S,BW,10)) mtry_params = np.zeros((S,BW,10)) etr_params[:,:,7] = dict_params['tfunc_avg_etr'] mtrx_params[:,:,7] = dict_params['tfunc_avg_mtrx'] mtry_params[:,:,7] = dict_params['tfunc_avg_mtry'] etr_params[:,:,9] = dict_params['tfunc_avg_etr'] mtrx_params[:,:,9] = dict_params['tfunc_avg_mtrx'] mtry_params[:,:,9] = dict_params['tfunc_avg_mtry'] etr_params[:,:,5] = 1.0 mtrx_params[:,:,5] = 1.0 mtry_params[:,:,5] = 1.0 # To zero out income taxes, uncomment the following 3 lines: # etr_params[:,:,6:] = 0.0 # mtrx_params[:,:,6:] = 0.0 # mtry_params[:,:,6:] = 0.0 # Wealth tax params # These are non-calibrated values, h and m just need # need to be nonzero to avoid errors. When p_wealth # is zero, there is no wealth tax. h_wealth = 0.1 m_wealth = 1.0 p_wealth = 0.0 # Bequest and Payroll Taxes tau_bq = np.zeros(J) tau_payroll = 0.0 #0.15 # were are inluding payroll taxes in tax functions for now retire = np.round(9.0 * S / 16.0) - 1 # Simulation Parameters MINIMIZER_TOL = 1e-14 MINIMIZER_OPTIONS = None PLOT_TPI = False maxiter = 250 mindist_SS = 1e-9 mindist_TPI = 2e-5 nu = .4 flag_graphs = False # Calibration parameters # These guesses are close to the calibrated values chi_b_guess = np.ones((J,)) * 80.0 #chi_b_guess = np.array([0.7, 0.7, 1.0, 1.2, 1.2, 1.2, 1.4]) #chi_b_guess = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 4.0, 10.0]) #chi_b_guess = np.array([5, 10, 90, 250, 250, 250, 250]) #chi_b_guess = np.array([2, 10, 90, 350, 1700, 22000, 120000]) chi_n_guess = np.array([38.12000874, 33.22762421, 25.34842241, 26.67954008, 24.41097278, 23.15059004, 22.46771332, 21.85495452, 21.46242013, 22.00364263, 21.57322063, 21.53371545, 21.29828515, 21.10144524, 20.8617942, 20.57282, 20.47473172, 20.31111347, 19.04137299, 18.92616951, 20.58517969, 20.48761429, 20.21744847, 19.9577682, 19.66931057, 19.6878927, 19.63107201, 19.63390543, 19.5901486, 19.58143606, 19.58005578, 19.59073213, 19.60190899, 19.60001831, 21.67763741, 21.70451784, 21.85430468, 21.97291208, 21.97017228, 22.25518398, 22.43969757, 23.21870602, 24.18334822, 24.97772026, 26.37663164, 29.65075992, 30.46944758, 31.51634777, 33.13353793, 32.89186997, 38.07083882, 39.2992811, 40.07987878, 35.19951571, 35.97943562, 37.05601334, 37.42979341, 37.91576867, 38.62775142, 39.4885405, 37.10609921, 40.03988031, 40.86564363, 41.73645892, 42.6208256, 43.37786072, 45.38166073, 46.22395387, 50.21419653, 51.05246704, 53.86896121, 53.90029708, 61.83586775, 64.87563699, 66.91207845, 68.07449767, 71.27919965, 73.57195873, 74.95045988, 76.62308152]) # Generate Income and Demographic parameters omega_hat, g_n_ss, omega_SS, surv_rate, rho, g_n_vector = get_omega( S, T, starting_age, ending_age, E, flag_graphs) # omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector = get_pop_objs( # E, S, T, 0, 100, 2015, flag_graphs) # print 'Differences:' # print 'omega diffs: ', (np.absolute(omega-omega2)).max() # print 'g_n', g_n_ss, g_n_ss2 # print 'omega SS diffs: ', (np.absolute(omega_SS-omega_SS2)).max() # print 'surv diffs: ', (np.absolute(surv_rate- surv_rate2)).max() # print 'mort diffs: ', (np.absolute(rho- rho2)).max() # print 'g_n_TP diffs: ', (np.absolute(g_n_vector- g_n_vector2)).max() # quit() #print 'omega_SS shape: ', omega_SS.shape 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() omega = np.tile(np.reshape(omega_SS,(1,S)),(T+S,1)) g_n_vector = np.tile(g_n_ss,(T+S,)) e_hetero = get_e(S, J, starting_age, ending_age, lambdas, omega_SS, flag_graphs) e = np.tile(((e_hetero*lambdas).sum(axis=1)).reshape(S,1),(1,J)) e /= (e * omega_SS.reshape(S, 1)* lambdas.reshape(1, J)).sum() allvars = dict(locals()) if user_modifiable: allvars = {k:allvars[k] for k in USER_MODIFIABLE_PARAMS} if metadata: params_meta = read_parameter_metadata() for k,v in allvars.iteritems(): params_meta[k]["value"] = v allvars = params_meta return allvars
def get_full_parameters(baseline, guid, user_modifiable, metadata): # Model Parameters S = int(80) J = int(7) T = int(2 * S) BW = int(10) lambdas = np.array([.25, .25, .2, .1, .1, .09, .01]) starting_age = 20 ending_age = 100 E = int(starting_age * (S / float(ending_age - starting_age))) beta_annual = .96 # Carroll (JME, 2009) beta = beta_annual ** (float(ending_age - starting_age) / S) 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)) Z = 1.0 delta_annual = .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 g_y = (1 + g_y_annual)**(float(ending_age - starting_age) / S) - 1 # Ellipse parameters frisch = 0.4 # Frisch elasticity consistent with Altonji (JPE, 1996) and Peterman (Econ Inquiry, 2016) b_ellipse, upsilon = elliptical_u_est.estimation(frisch,ltilde) k_ellipse = 0 # this parameter is just a level shifter in utlitiy - irrelevant for analysis # Tax parameters: # Income Tax Parameters # will call tax function estimation function here... # do output such that each parameters is in a separate SxBW array # read in estimated parameters print 'baselines is:', baseline if baseline: baseline_pckl = "TxFuncEst_baseline{}.pkl".format(guid) estimate_file = os.path.join(TAX_ESTIMATE_PATH, baseline_pckl) print 'using baseline2 tax parameters' dict_params = read_tax_func_estimate(estimate_file, baseline_pckl) else: policy_pckl = "TxFuncEst_policy{}.pkl".format(guid) estimate_file = os.path.join(TAX_ESTIMATE_PATH, policy_pckl) print 'using policy2 tax parameters' dict_params = read_tax_func_estimate(estimate_file, policy_pckl) mean_income_data = dict_params['tfunc_avginc'][0] etr_params = dict_params['tfunc_etr_params_S'][:S,:BW,:] mtrx_params = dict_params['tfunc_mtrx_params_S'][:S,:BW,:] mtry_params = dict_params['tfunc_mtry_params_S'][:S,:BW,:] # To zero out income taxes, uncomment the following 3 lines: # etr_params[:,:,6:] = 0.0 # mtrx_params[:,:,6:] = 0.0 # mtry_params[:,:,6:] = 0.0 # Wealth tax params # These are non-calibrated values, h and m just need # need to be nonzero to avoid errors. When p_wealth # is zero, there is no wealth tax. h_wealth = 0.1 m_wealth = 1.0 p_wealth = 0.0 # Bequest and Payroll Taxes tau_bq = np.zeros(J) tau_payroll = 0.0 #0.15 # were are inluding payroll taxes in tax functions for now retire = np.round(9.0 * S / 16.0) - 1 # Simulation Parameters MINIMIZER_TOL = 1e-14 MINIMIZER_OPTIONS = None PLOT_TPI = False maxiter = 250 mindist_SS = 1e-9 mindist_TPI = 2e-5 nu = .4 flag_graphs = False # Calibration parameters # These guesses are close to the calibrated values #chi_b_guess = np.array([0.7, 0.7, 1.0, 1.2, 1.2, 1.2, 1.4]) chi_b_guess = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) chi_n_guess = np.array([38.12000874, 33.22762421, 25.34842241, 26.67954008, 24.41097278, 23.15059004, 22.46771332, 21.85495452, 21.46242013, 22.00364263, 21.57322063, 21.53371545, 21.29828515, 21.10144524, 20.8617942, 20.57282, 20.47473172, 20.31111347, 19.04137299, 18.92616951, 20.58517969, 20.48761429, 20.21744847, 19.9577682, 19.66931057, 19.6878927, 19.63107201, 19.63390543, 19.5901486, 19.58143606, 19.58005578, 19.59073213, 19.60190899, 19.60001831, 21.67763741, 21.70451784, 21.85430468, 21.97291208, 21.97017228, 22.25518398, 22.43969757, 23.21870602, 24.18334822, 24.97772026, 26.37663164, 29.65075992, 30.46944758, 31.51634777, 33.13353793, 32.89186997, 38.07083882, 39.2992811, 40.07987878, 35.19951571, 35.97943562, 37.05601334, 37.42979341, 37.91576867, 38.62775142, 39.4885405, 37.10609921, 40.03988031, 40.86564363, 41.73645892, 42.6208256, 43.37786072, 45.38166073, 46.22395387, 50.21419653, 51.05246704, 53.86896121, 53.90029708, 61.83586775, 64.87563699, 66.91207845, 68.07449767, 71.27919965, 73.57195873, 74.95045988, 76.62308152]) # Generate Income and Demographic parameters omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector = get_omega( S, T, starting_age, ending_age, E, flag_graphs) e = get_e(S, J, starting_age, ending_age, lambdas, omega_SS, flag_graphs) allvars = dict(locals()) if user_modifiable: allvars = {k:allvars[k] for k in USER_MODIFIABLE_PARAMS} if metadata: params_meta = read_parameter_metadata() for k,v in allvars.iteritems(): params_meta[k]["value"] = v allvars = params_meta return allvars
def get_full_parameters(baseline, guid, user_modifiable, metadata): # Model Parameters S = int(80) J = int(7) T = int(2 * S) BW = int(10) lambdas = np.array([.25, .25, .2, .1, .1, .09, .01]) starting_age = 20 ending_age = 100 E = int(starting_age * (S / float(ending_age - starting_age))) beta_annual = .96 # Carroll (JME, 2009) beta = beta_annual**(float(ending_age - starting_age) / S) 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)) Z = 1.0 delta_annual = .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 g_y = (1 + g_y_annual)**(float(ending_age - starting_age) / S) - 1 # Ellipse parameters frisch = 0.4 # Frisch elasticity consistent with Altonji (JPE, 1996) and Peterman (Econ Inquiry, 2016) b_ellipse, upsilon = elliptical_u_est.estimation(frisch, ltilde) k_ellipse = 0 # this parameter is just a level shifter in utlitiy - irrelevant for analysis # Tax parameters: # Income Tax Parameters # will call tax function estimation function here... # do output such that each parameters is in a separate SxBW array # read in estimated parameters print 'baselines is:', baseline if baseline: baseline_pckl = "TxFuncEst_baseline{}.pkl".format(guid) estimate_file = os.path.join(TAX_ESTIMATE_PATH, baseline_pckl) print 'using baseline2 tax parameters' dict_params = read_tax_func_estimate(estimate_file, baseline_pckl) else: policy_pckl = "TxFuncEst_policy{}.pkl".format(guid) estimate_file = os.path.join(TAX_ESTIMATE_PATH, policy_pckl) print 'using policy2 tax parameters' dict_params = read_tax_func_estimate(estimate_file, policy_pckl) mean_income_data = dict_params['tfunc_avginc'][0] etr_params = dict_params['tfunc_etr_params_S'][:S, :BW, :] mtrx_params = dict_params['tfunc_mtrx_params_S'][:S, :BW, :] mtry_params = dict_params['tfunc_mtry_params_S'][:S, :BW, :] # To zero out income taxes, uncomment the following 3 lines: # etr_params[:,:,6:] = 0.0 # mtrx_params[:,:,6:] = 0.0 # mtry_params[:,:,6:] = 0.0 # Wealth tax params # These are non-calibrated values, h and m just need # need to be nonzero to avoid errors. When p_wealth # is zero, there is no wealth tax. h_wealth = 0.1 m_wealth = 1.0 p_wealth = 0.0 # Bequest and Payroll Taxes tau_bq = np.zeros(J) tau_payroll = 0.0 #0.15 # were are inluding payroll taxes in tax functions for now retire = np.round(9.0 * S / 16.0) - 1 # Simulation Parameters MINIMIZER_TOL = 1e-14 MINIMIZER_OPTIONS = None PLOT_TPI = False maxiter = 250 mindist_SS = 1e-9 mindist_TPI = 2e-5 nu = .4 flag_graphs = False # Calibration parameters # These guesses are close to the calibrated values #chi_b_guess = np.array([0.7, 0.7, 1.0, 1.2, 1.2, 1.2, 1.4]) chi_b_guess = np.array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]) chi_n_guess = np.array([ 38.12000874, 33.22762421, 25.34842241, 26.67954008, 24.41097278, 23.15059004, 22.46771332, 21.85495452, 21.46242013, 22.00364263, 21.57322063, 21.53371545, 21.29828515, 21.10144524, 20.8617942, 20.57282, 20.47473172, 20.31111347, 19.04137299, 18.92616951, 20.58517969, 20.48761429, 20.21744847, 19.9577682, 19.66931057, 19.6878927, 19.63107201, 19.63390543, 19.5901486, 19.58143606, 19.58005578, 19.59073213, 19.60190899, 19.60001831, 21.67763741, 21.70451784, 21.85430468, 21.97291208, 21.97017228, 22.25518398, 22.43969757, 23.21870602, 24.18334822, 24.97772026, 26.37663164, 29.65075992, 30.46944758, 31.51634777, 33.13353793, 32.89186997, 38.07083882, 39.2992811, 40.07987878, 35.19951571, 35.97943562, 37.05601334, 37.42979341, 37.91576867, 38.62775142, 39.4885405, 37.10609921, 40.03988031, 40.86564363, 41.73645892, 42.6208256, 43.37786072, 45.38166073, 46.22395387, 50.21419653, 51.05246704, 53.86896121, 53.90029708, 61.83586775, 64.87563699, 66.91207845, 68.07449767, 71.27919965, 73.57195873, 74.95045988, 76.62308152 ]) # Generate Income and Demographic parameters omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector = get_omega( S, T, starting_age, ending_age, E, flag_graphs) e = get_e(S, J, starting_age, ending_age, lambdas, omega_SS, flag_graphs) allvars = dict(locals()) if user_modifiable: allvars = {k: allvars[k] for k in USER_MODIFIABLE_PARAMS} if metadata: params_meta = read_parameter_metadata() for k, v in allvars.iteritems(): params_meta[k]["value"] = v allvars = params_meta return allvars
def get_full_parameters(): # Model Parameters S = 80 J = 7 T = int(2 * S) lambdas = np.array([.25, .25, .2, .1, .1, .09, .01]) starting_age = 20 ending_age = 100 E = int(starting_age * (S / float(ending_age - starting_age))) beta_annual = .96 beta = beta_annual**(float(ending_age - starting_age) / S) sigma = 3.0 alpha = .35 Z = 1.0 delta_annual = .05 delta = 1 - ((1 - delta_annual)**(float(ending_age - starting_age) / S)) ltilde = 1.0 g_y_annual = 0.03 g_y = (1 + g_y_annual)**(float(ending_age - starting_age) / S) - 1 # Ellipse parameters b_ellipse = 25.6594 k_ellipse = -26.4902 upsilon = 3.0542 # Tax parameters: # Income Tax Parameters mean_income_data = 84377.0 a_tax_income = 3.03452713268985e-06 b_tax_income = .222 c_tax_income = 133261.0 d_tax_income = .219 # Wealth tax params # These are non-calibrated values, h and m just need # need to be nonzero to avoid errors. When p_wealth # is zero, there is no wealth tax. h_wealth = 0.1 m_wealth = 1.0 p_wealth = 0.0 # Bequest and Payroll Taxes tau_bq = np.zeros(J) tau_payroll = 0.15 retire = np.round(9.0 * S / 16.0) - 1 # Simulation Parameters MINIMIZER_TOL = 1e-14 MINIMIZER_OPTIONS = None PLOT_TPI = True maxiter = 250 mindist_SS = 1e-9 mindist_TPI = 1e-6 nu = .4 flag_graphs = False # Calibration parameters # These guesses are close to the calibrated values chi_b_guess = np.array([2, 10, 90, 350, 1700, 22000, 120000]) chi_n_guess = np.array([ 47.12000874, 22.22762421, 14.34842241, 10.67954008, 8.41097278, 7.15059004, 6.46771332, 5.85495452, 5.46242013, 5.00364263, 4.57322063, 4.53371545, 4.29828515, 4.10144524, 3.8617942, 3.57282, 3.47473172, 3.31111347, 3.04137299, 2.92616951, 2.58517969, 2.48761429, 2.21744847, 1.9577682, 1.66931057, 1.6878927, 1.63107201, 1.63390543, 1.5901486, 1.58143606, 1.58005578, 1.59073213, 1.60190899, 1.60001831, 1.67763741, 1.70451784, 1.85430468, 1.97291208, 1.97017228, 2.25518398, 2.43969757, 3.21870602, 4.18334822, 4.97772026, 6.37663164, 8.65075992, 9.46944758, 10.51634777, 12.13353793, 11.89186997, 12.07083882, 13.2992811, 14.07987878, 14.19951571, 14.97943562, 16.05601334, 16.42979341, 16.91576867, 17.62775142, 18.4885405, 19.10609921, 20.03988031, 20.86564363, 21.73645892, 22.6208256, 23.37786072, 24.38166073, 25.22395387, 26.21419653, 27.05246704, 27.86896121, 28.90029708, 29.83586775, 30.87563699, 31.91207845, 33.07449767, 34.27919965, 35.57195873, 36.95045988, 38.62308152 ]) # Generate Income and Demographic parameters omega, g_n_ss, omega_SS, surv_rate, rho, g_n_vector = get_omega( S, T, starting_age, ending_age, E, flag_graphs) e = get_e(S, J, starting_age, ending_age, lambdas, omega_SS, flag_graphs) allvars = dict(locals()) return allvars