def test_MTR_wealth(): # Test marginal tax rate on wealth b = np.array([0.2, 0.6, 0.8]) h_wealth = 3 p_wealth = 4 m_wealth = 5 tau_w_prime = tax.MTR_wealth(b, (h_wealth, p_wealth, m_wealth)) assert np.allclose(tau_w_prime, np.array([1.91326531, 1.29757785, 1.09569028]))
def FOC_savings(r, w, b, b_splus1, n, bq, factor, tr, theta, e, rho, tau_c, etr_params, mtry_params, t, j, p, method): r''' Computes Euler errors for the FOC for savings in the steady state. This function is usually looped through over J, so it does one lifetime income group at a time. .. math:: c_{j,s,t}^{-\sigma} = e^{-\sigma g_y}\biggl[\chi^b_j\rho_s(b_{j,s+1,t+1})^{-\sigma} + \beta\bigl(1 - \rho_s\bigr)\Bigl(1 + r_{t+1}\bigl[1 - \tau^{mtry}_{s+1,t+1}\bigr]\Bigr)(c_{j,s+1,t+1})^{-\sigma}\biggr] Args: r (array_like): the real interest rate w (array_like): the real wage rate b (Numpy array): household savings b_splus1 (Numpy array): household savings one period ahead b_splus2 (Numpy array): household savings two periods ahead n (Numpy array): household labor supply bq (Numpy array): household bequests received factor (scalar): scaling factor converting model units to dollars tr (Numpy array): government tranfers to household theta (Numpy array): social security replacement rate for each lifetime income group e (Numpy array): effective labor units rho (Numpy array): mortality rates tau_c (array_like): consumption tax rates etr_params (Numpy array): parameters of the effective tax rate functions mtry_params (Numpy array): parameters of the marginal tax rate on capital income functions t (int): model period j (int): index of ability type p (OG-USA Specifications object): model parameters method (str): adjusts calculation dimensions based on 'SS' or 'TPI' Returns: euler (Numpy array): Euler error from FOC for savings ''' if j is not None: chi_b = p.chi_b[j] else: chi_b = p.chi_b if method == 'SS': h_wealth = p.h_wealth[-1] m_wealth = p.m_wealth[-1] p_wealth = p.p_wealth[-1] else: h_wealth = p.h_wealth[t] m_wealth = p.m_wealth[t] p_wealth = p.p_wealth[t] taxes = tax.total_taxes(r, w, b, n, bq, factor, tr, theta, t, j, False, method, e, etr_params, p) cons = get_cons(r, w, b, b_splus1, n, bq, taxes, e, tau_c, p) deriv = ((1 + r) - (r * tax.MTR_income(r, w, b, n, factor, True, e, etr_params, mtry_params, p)) - tax.MTR_wealth(b, h_wealth, m_wealth, p_wealth)) savings_ut = (rho * np.exp(-p.sigma * p.g_y) * chi_b * b_splus1**(-p.sigma)) euler_error = np.zeros_like(n) if n.shape[0] > 1: euler_error[:-1] = ( marg_ut_cons(cons[:-1], p.sigma) * (1 / (1 + tau_c[:-1])) - p.beta * (1 - rho[:-1]) * deriv[1:] * marg_ut_cons(cons[1:], p.sigma) * (1 / (1 + tau_c[1:])) * np.exp(-p.sigma * p.g_y) - savings_ut[:-1]) euler_error[-1] = (marg_ut_cons(cons[-1], p.sigma) * (1 / (1 + tau_c[-1])) - savings_ut[-1]) else: euler_error[-1] = (marg_ut_cons(cons[-1], p.sigma) * (1 / (1 + tau_c[-1])) - savings_ut[-1]) return euler_error
def test_MTR_wealth(b, p, expected): # Test marginal tax rate on wealth tau_w_prime = tax.MTR_wealth(b, p.h_wealth[:p.T], p.m_wealth[:p.T], p.p_wealth[:p.T]) assert np.allclose(tau_w_prime, expected)