예제 #1
0
파일: TPI.py 프로젝트: jdebacker/wealthtax
Lpath_TPI = np.array(list(Linit) + list(np.ones(10)*Lss))
BQpath_TPI = np.array(list(BQinit) + list(np.ones((10, J))*BQss))


b_s = np.zeros((T, S, J))
b_s[:, 1:, :] = b_mat[:T, :-1, :]
b_splus1 = np.zeros((T, S, J))
b_splus1[:, :, :] = b_mat[1:T+1, :, :]

tax_path = tax.total_taxes(rinit[:T].reshape(T, 1, 1), b_s, winit[:T].reshape(T, 1, 1), e.reshape(
    1, S, J), n_mat[:T], BQinit[:T, :].reshape(T, 1, J), lambdas, factor_ss, T_H_init[:T].reshape(T, 1, 1), None, 'TPI', False, parameters, theta, tau_bq)
c_path = house.get_cons(rinit[:T].reshape(T, 1, 1), b_s, winit[:T].reshape(T, 1, 1), e.reshape(1, S, J), n_mat[:T], BQinit[:T].reshape(T, 1, J), lambdas.reshape(1, 1, J), b_splus1, parameters, tax_path)

Y_path = firm.get_Y(Kpath_TPI[:T], Lpath_TPI[:T], parameters)
C_path = (c_path * omega_stationary[:T].reshape(T, S, 1) * lambdas).sum(1).sum(1)
I_path = firm.get_I(Kpath_TPI[1:T+1], Kpath_TPI[:T], delta, g_y, g_n_vector[:T])
print 'Resource Constraint Difference:', Y_path - C_path - I_path

print'Checking time path for violations of constaints.'
for t in xrange(T):
    house.constraint_checker_TPI(b_mat[t], n_mat[t], c_path[t], t, parameters)

eul_savings = euler_errors[:, :S, :].max(1).max(1)
eul_laborleisure = euler_errors[:, S:, :].max(1).max(1)

'''
------------------------------------------------------------------------
Save variables/values so they can be used in other modules
------------------------------------------------------------------------
'''
예제 #2
0
r_base = rinit
Y_base = Yinit
BQpath_TPIbase = BQpath_TPI
eul_savings_init = eul_savings
eul_laborleisure_init = eul_laborleisure
b_mat_init = b_mat
n_mat_init = n_mat
T_H_initbase = T_H_init

b1 = np.zeros((T, S, J))
b1[:, 1:, :] = b_mat_init[:T, :-1, :]
b2 = np.zeros((T, S, J))
b2[:, :, :] = b_mat_init[:T, :, :]
c_path_init = c_path

inv_mat_init = firm.get_I(b_mat_init[1:T + 1], b_mat_init[:T], delta, g_y,
                          g_n_vector[:T].reshape(T, 1, 1))
y_mat_init = c_path_init + inv_mat_init

# Lifetime Utility Graphs:
c_ut_init = np.zeros((S, S, J))
for s in xrange(S - 1):
    c_ut_init[:, s + 1, :] = c_path_init[s + 1:s + 1 + S, s + 1, :]
c_ut_init[:, 0, :] = c_path_init[:S, 0, :]
L_ut_init = np.zeros((S, S, J))
for s in xrange(S - 1):
    L_ut_init[:, s + 1, :] = n_mat_init[s + 1:s + 1 + S, s + 1, :]
L_ut_init[:, 0, :] = n_mat_init[:S, 0, :]
B_ut_init = BQpath_TPIbase[S:T]
b_ut_init = np.zeros((S, S, J))
for s in xrange(S):
    b_ut_init[:, s, :] = b_mat_init[s:s + S, s, :]
예제 #3
0
파일: SS.py 프로젝트: lnsongxf/wealthtax
    Generate the SS values of variables, including euler errors
------------------------------------------------------------------------
'''

bssmat = solutions[0:(S-1) * J].reshape(S-1, J)
bq = solutions[(S-1)*J:S*J]
bssmat_s = np.array(list(np.zeros(J).reshape(1, J)) + list(bssmat))
bssmat_splus1 = np.array(list(bssmat) + list(bq.reshape(1, J)))
nssmat = solutions[S * J:2*S*J].reshape(S, J)
wss, rss, factor_ss, T_Hss = solutions[2*S*J:]

Kss = house.get_K(bssmat_splus1, omega_SS.reshape(S, 1), lambdas, g_n_ss)
Lss = firm.get_L(e, nssmat, omega_SS.reshape(S, 1), lambdas)
Yss = firm.get_Y(Kss, Lss, parameters)

Iss = firm.get_I(Kss, Kss, delta, g_y, g_n_ss)

theta = tax.replacement_rate_vals(nssmat, wss, factor_ss, e, J, omega_SS.reshape(S, 1), lambdas)
BQss = house.get_BQ(rss, bssmat_splus1, omega_SS.reshape(S, 1), lambdas, rho.reshape(S, 1), g_n_ss)
b_s = np.array(list(np.zeros(J).reshape((1, J))) + list(bssmat))
taxss = tax.total_taxes(rss, b_s, wss, e, nssmat, BQss, lambdas, factor_ss, T_Hss, None, 'SS', False, parameters, theta, tau_bq)
cssmat = house.get_cons(rss, b_s, wss, e, nssmat, BQss.reshape(1, J), lambdas.reshape(1, J), bssmat_splus1, parameters, taxss)

Css = house.get_C(cssmat, omega_SS.reshape(S, 1), lambdas)

resource_constraint = Yss - (Css + Iss)

print 'Resource Constraint Difference:', resource_constraint

house.constraint_checker_SS(bssmat, nssmat, cssmat, parameters)
예제 #4
0
Y_base = Yinit
BQpath_TPIbase = BQpath_TPI
eul_savings_init = eul_savings
eul_laborleisure_init = eul_laborleisure
b_mat_init = b_mat
n_mat_init = n_mat
T_H_initbase = T_H_init


b1 = np.zeros((T, S, J))
b1[:, 1:, :] = b_mat_init[:T, :-1, :]
b2 = np.zeros((T, S, J))
b2[:, :, :] = b_mat_init[:T, :, :]
c_path_init = c_path

inv_mat_init = firm.get_I(b_mat_init[1:T+1], b_mat_init[:T], delta, g_y, g_n_vector[:T].reshape(T, 1, 1))
y_mat_init = c_path_init + inv_mat_init

# Lifetime Utility Graphs:
c_ut_init = np.zeros((S, S, J))
for s in xrange(S-1):
    c_ut_init[:, s+1, :] = c_path_init[s+1:s+1+S, s+1, :]
c_ut_init[:, 0, :] = c_path_init[:S, 0, :]
L_ut_init = np.zeros((S, S, J))
for s in xrange(S-1):
    L_ut_init[:, s+1, :] = n_mat_init[s+1:s+1+S, s+1, :]
L_ut_init[:, 0, :] = n_mat_init[:S, 0, :]
B_ut_init = BQpath_TPIbase[S:T]
b_ut_init = np.zeros((S, S, J))
for s in xrange(S):
    b_ut_init[:, s, :] = b_mat_init[s:s+S, s, :]
예제 #5
0
파일: TPI.py 프로젝트: lnsongxf/wealthtax
tax_path = tax.total_taxes(rinit[:T].reshape(T, 1, 1), b_s,
                           winit[:T].reshape(T, 1, 1), e.reshape(1, S, J),
                           n_mat[:T], BQinit[:T, :].reshape(T, 1, J), lambdas,
                           factor_ss, T_H_init[:T].reshape(T, 1, 1), None,
                           'TPI', False, parameters, theta, tau_bq)
c_path = house.get_cons(rinit[:T].reshape(T, 1,
                                          1), b_s, winit[:T].reshape(T, 1, 1),
                        e.reshape(1, S,
                                  J), n_mat[:T], BQinit[:T].reshape(T, 1, J),
                        lambdas.reshape(1, 1, J), b_splus1, parameters,
                        tax_path)

Y_path = firm.get_Y(Kpath_TPI[:T], Lpath_TPI[:T], parameters)
C_path = (c_path * omega_stationary[:T].reshape(T, S, 1) *
          lambdas).sum(1).sum(1)
I_path = firm.get_I(Kpath_TPI[1:T + 1], Kpath_TPI[:T], delta, g_y,
                    g_n_vector[:T])
print 'Resource Constraint Difference:', Y_path - C_path - I_path

print 'Checking time path for violations of constaints.'
for t in xrange(T):
    house.constraint_checker_TPI(b_mat[t], n_mat[t], c_path[t], t, parameters)

eul_savings = euler_errors[:, :S, :].max(1).max(1)
eul_laborleisure = euler_errors[:, S:, :].max(1).max(1)
'''
------------------------------------------------------------------------
Save variables/values so they can be used in other modules
------------------------------------------------------------------------
'''

var_names = [
예제 #6
0
savings = np.copy(bssmat_splus1)

beq_ut = chi_b.reshape(S, J) * (rho.reshape(
    S, 1)) * (savings**(1 - sigma) - 1) / (1 - sigma)
utility = ((cssmat_init**(1 - sigma) - 1) / (1 - sigma)) + chi_n.reshape(
    S, 1) * (b_ellipse *
             (1 - (nssmat_init / ltilde)**upsilon)**(1 / upsilon) + k_ellipse)
utility += beq_ut
utility_init = utility.sum(0)

T_Hss_init = T_Hss
Kss_init = Kss
Lss_init = Lss

Css_init = house.get_C(cssmat, omega_SS.reshape(S, 1), lambdas)
iss_init = firm.get_I(bssmat_splus1, bssmat_splus1, delta, g_y, g_n_ss)
income_init = cssmat + iss_init
# print (income_init*omega_SS).sum()
# print Css + delta * Kss
# print Kss
# print Lss
# print Css_init
# print (utility_init * omega_SS).sum()
the_inequalizer(income_init, omega_SS, lambdas, S, J)
'''
------------------------------------------------------------------------
    SS baseline graphs
------------------------------------------------------------------------
'''

domain = np.linspace(starting_age, ending_age, S)
예제 #7
0
factor_ss_init = factor_ss

savings = np.copy(bssmat_splus1)

beq_ut = chi_b.reshape(S, J) * (rho.reshape(S, 1)) * (savings**(1-sigma) -1)/(1-sigma)
utility = ((cssmat_init ** (1-sigma) - 1)/(1- sigma)) + chi_n.reshape(S, 1) * (b_ellipse * (1-(nssmat_init/ltilde)**upsilon) ** (1/upsilon) + k_ellipse)
utility += beq_ut 
utility_init = utility.sum(0)

T_Hss_init = T_Hss
Kss_init = Kss
Lss_init = Lss

Css_init = house.get_C(cssmat, omega_SS.reshape(S, 1), lambdas)
iss_init = firm.get_I(bssmat_splus1, bssmat_splus1, delta, g_y, g_n_ss)
income_init = cssmat + iss_init
# print (income_init*omega_SS).sum()
# print Css + delta * Kss
# print Kss
# print Lss
# print Css_init
# print (utility_init * omega_SS).sum()
the_inequalizer(income_init, omega_SS, lambdas, S, J)



'''
------------------------------------------------------------------------
    SS baseline graphs
------------------------------------------------------------------------