def Euler1(w, r, e, n_guess, b1, b2, b3, BQ, factor, T_H, chi_b): ''' Parameters: w = wage rate (scalar) r = rental rate (scalar) e = distribution of abilities (SxJ array) n_guess = distribution of labor (SxJ array) b1 = distribution of capital in period t ((S-1) x J array) b2 = distribution of capital in period t+1 ((S-1) x J array) b3 = distribution of capital in period t+2 ((S-1) x J array) B = distribution of incidental bequests (1 x J array) factor = scaling value to make average income match data T_H = lump sum transfer from the government to the households xi = coefficient of relative risk aversion chi_b = discount factor of savings Returns: Value of Euler error. ''' BQ_euler = BQ.reshape(1, J) tax1 = tax.total_taxes_SS(r, b1, w, e[:-1, :], n_guess[:-1, :], BQ_euler, lambdas, factor, T_H) tax2 = tax.total_taxes_SS2(r, b2, w, e[1:, :], n_guess[1:, :], BQ_euler, lambdas, factor, T_H) cons1 = get_cons(r, b1, w, e[:-1, :], n_guess[:-1, :], BQ_euler, lambdas, b2, g_y, tax1) cons2 = get_cons(r, b2, w, e[1:, :], n_guess[1:, :], BQ_euler, lambdas, b3, g_y, tax2) income = (r * b2 + w * e[1:, :] * n_guess[1:, :]) * factor deriv = ( 1 + r*(1-tax.tau_income(r, b1, w, e[1:, :], n_guess[1:, :], factor)-tax.tau_income_deriv( r, b1, w, e[1:, :], n_guess[1:, :], factor)*income)-tax.tau_w_prime(b2)*b2-tax.tau_wealth(b2)) bequest_ut = rho[:-1].reshape(S-1, 1) * np.exp(-sigma * g_y) * chi_b[:-1].reshape(S-1, J) * b2 ** (-sigma) euler = MUc(cons1) - beta * (1-rho[:-1].reshape(S-1, 1)) * deriv * MUc( cons2) * np.exp(-sigma * g_y) - bequest_ut return euler
def Euler1(w, r, e, L_guess, K1, K2, K3, B, factor, taulump, chi_b): ''' Parameters: w = wage rate (scalar) r = rental rate (scalar) e = distribution of abilities (SxJ array) L_guess = distribution of labor (SxJ array) K1 = distribution of capital in period t ((S-1) x J array) K2 = distribution of capital in period t+1 ((S-1) x J array) K3 = distribution of capital in period t+2 ((S-1) x J array) B = distribution of incidental bequests (1 x J array) factor = scaling value to make average income match data taulump = lump sum transfer from the government to the households xi = coefficient of relative risk aversion chi_b = discount factor of savings Returns: Value of Euler error. ''' B_euler = B.reshape(1, J) tax1 = tax.total_taxes_SS(r, K1, w, e[:-1, :], L_guess[:-1, :], B_euler, bin_weights, factor, taulump) tax2 = tax.total_taxes_SS2(r, K2, w, e[1:, :], L_guess[1:, :], B_euler, bin_weights, factor, taulump) cons1 = get_cons(r, K1, w, e[:-1, :], L_guess[:-1, :], B_euler, bin_weights, K2, g_y, tax1) cons2 = get_cons(r, K2, w, e[1:, :], L_guess[1:, :], B_euler, bin_weights, K3, g_y, tax2) income = (r * K2 + w * e[1:, :] * L_guess[1:, :]) * factor deriv = ( 1 + r*(1-tax.tau_income(r, K1, w, e[1:, :], L_guess[1:, :], factor)-tax.tau_income_deriv( r, K1, w, e[1:, :], L_guess[1:, :], factor)*income)-tax.tau_w_prime(K2)*K2-tax.tau_wealth(K2)) bequest_ut = (1-surv_rate[:-1].reshape(S-1, 1)) * np.exp(-sigma * g_y) * chi_b[:-1].reshape(S-1, J) * K2 ** (-sigma) euler = MUc(cons1) - beta * surv_rate[:-1].reshape(S-1, 1) * deriv * MUc( cons2) * np.exp(-sigma * g_y) - bequest_ut return euler