nkids0=x_df[ ['nkids_baseline'] ].values #marital status at baseline married0=x_df[ ['d_marital_2'] ].values #age of child at baseline agech0_a=x_df[['age_t0A']].values[:,0] agech0_b=x_df[['age_t0B']].values[:,0] d_childb=x_df[['d_childB']].values d_childa=x_df[['d_childA']].values """ #Defines the instance with parameters param0 = util.Parameters(alphap, alphaf, eta, gamma1, gamma2, gamma3, tfp, sigma2theta, varphi, rho_theta_epsilon, rho_theta_ab, wagep_betas, income_male_betas, marriagep_betas, kidsp_betas, eitc_list, afdc_list, snap_list, cpi, lambdas, kappas, pafdc, psnap, mup) #For montercarlo integration D = 20 #How many hours is part- and full-time work hours_p = 15 hours_f = 40 hours = np.zeros(N) childcare = np.zeros(N) wr, cs, ws = 1, 1, 1 ######################################################################
def elast_gen(bs, shocks): eta = bs[0] alphap = bs[1] alphaf = bs[2] #wage process wagep_betas = np.array([bs[3], bs[4], bs[5], bs[6], bs[7]]).reshape((5, 1)) #Production function [young[cc0,cc1],old] gamma1 = bs[8] gamma2 = bs[9] gamma3 = bs[10] tfp = bs[11] kappas = [[bs[12], bs[13], bs[14], bs[15]], [bs[16], bs[17], bs[18], bs[19]]] rho_theta_epsilon = bs[20] lambdas = [1, 1] #Re-defines the instance with parameters param = util.Parameters(alphap, alphaf, eta, gamma1, gamma2, gamma3, tfp, sigma2theta, rho_theta_epsilon, wagep_betas, marriagep_betas, kidsp_betas, eitc_list, afdc_list, snap_list, cpi, lambdas, kappas, pafdc, psnap, mup) #The estimate class output_ins = estimate.Estimate(nperiods, param, x_w, x_m, x_k, x_wmk, passign, agech0, nkids0, married0, D, dict_grid, M, N, moments_vector, var_cov, hours_p, hours_f, wr, cs, ws) hours = np.zeros(N) childcare = np.zeros(N) model_orig = util.Utility(param, N, x_w, x_m, x_k, passign, nkids0, married0, hours, childcare, agech0, hours_p, hours_f, wr, cs, ws) #Obtaining emax instance: this is fixed throughout the exercise emax_instance = output_ins.emax(param, model_orig) choices_c = {} models = [] for j in range(2): np.save( '/mnt/Research/nealresearch/new-hope-secure/newhopemount/results/Model/experiments/NH/shock.npy', shocks[j]) models.append( Shock(param, N, x_w, x_m, x_k, passign, nkids0, married0, hours, childcare, agech0, hours_p, hours_f, wr, cs, ws)) choices_c['Choice_' + str(j)] = output_ins.samples( param, emax_instance, models[j]) #Computing changes in % employment for control group h_sim_matrix = [] employment = [] wages = [] full = [] for j in range(2): h_sim_matrix.append(choices_c['Choice_' + str(j)]['hours_matrix']) employment.append(choices_c['Choice_' + str(j)]['hours_matrix'] > 0) full.append(choices_c['Choice_' + str(j)]['hours_matrix'] == hours_f) wages.append(choices_c['Choice_' + str(j)]['wage_matrix']) #Extensive margin elast_extensive = np.zeros(M) for j in range(M): elast_periods = np.zeros(nperiods) for t in range(nperiods): elast_periods[t] = np.mean( (employment[1][:, t, j] - employment[0][:, t, j]), axis=0) / (shocks[1] * np.mean( (employment[0][:, t, j]), axis=0)) elast_extensive[j] = np.mean(elast_periods) #Intensive margin elast_intensive = np.zeros(M) for j in range(M): elast_periods = np.zeros(nperiods) for t in range(nperiods): sample = (employment[0][:, t, j] == 1) elast_periods[t] = np.mean( (h_sim_matrix[1][sample, t, j] - h_sim_matrix[0][sample, t, j]), axis=0) / (shocks[1] * np.mean(h_sim_matrix[0][sample, t, j], axis=0)) elast_intensive[j] = np.mean(elast_periods) return {'Extensive': elast_extensive, 'Intensive': elast_intensive}
nkids0 = x_df[['nkids_baseline']].values #marital status at baseline married0 = x_df[['d_marital_2']].values #age of child at baseline agech0 = x_df[['age_t0']].values age_child = np.zeros((N, nperiods)) for t in range(nperiods): age_child = agech0 + t #Defines the instance with parameters param0 = util.Parameters(alphap, alphaf, mu_c, eta, gamma1, gamma2, gamma3, tfp, sigma2theta, rho_theta_epsilon, wagep_betas, income_male_betas, c_emp_spouse, marriagep_betas, kidsp_betas, eitc_list, afdc_list, snap_list, cpi, fpl_list, lambdas, kappas, pafdc, psnap, mup, sigma_z) ###Auxiliary estimates### moments_vector = pd.read_csv( "/home/jrodriguez/NH_HC/results/model_v2/aux_model/moments_vector.csv" ).values #This is the var cov matrix of aux estimates var_cov = pd.read_csv( "/home/jrodriguez/NH_HC/results/model_v2/aux_model/var_cov.csv").values #The vector of aux standard errors #Using diagonal of Var-Cov matrix of simulated moments se_vector = np.sqrt(np.diagonal(var_cov))
#Assuming random start theta0 = np.exp(np.random.randn(N)) #number of kids at baseline nkids0 = x_df[['nkids_baseline']].values #marital status at baseline married0 = x_df[['d_marital_2']].values #age of child at baseline agech0 = x_df[['age_t0']].values #Defines the instance with parameters param0 = util.Parameters(alphap, alphaf, eta, alpha_cc, gamma1, gamma2, tfp, sigmatheta, wagep_betas, marriagep_betas, kidsp_betas, eitc_list, afdc_list, snap_list, cpi, q, scalew, shapew, lambdas, kappas, pafdc, psnap) #For montercarlo integration D = [5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 70, 80, 90, 100] #How many hours is part- and full-time work hours_p = 15 hours_f = 40 hours = np.zeros(N) childcare = np.zeros(N) wr, cs, ws = 1, 1, 1 #This is an arbitrary initialization of Utility class model = util.Utility(param0, N, x_w, x_m, x_k, passign, nkids0, married0,