def test_ETR_wealth(): # Test wealth tax computation b = np.array([0.1, 0.5, 0.9]) h_wealth = 2 p_wealth = 3 m_wealth = 4 tau_w_prime = tax.ETR_wealth(b, (h_wealth, p_wealth, m_wealth)) assert np.allclose(tau_w_prime, np.array([0.14285714, 0.6, 0.93103448]))
def test_ETR_wealth(b, p, expected): # Test wealth tax computation tau_w = tax.ETR_wealth(b, p.h_wealth[:p.T], p.m_wealth[:p.T], p.p_wealth[:p.T]) assert np.allclose(tau_w, expected)
def revenue(r, w, b, n, bq, c, Y, L, K, factor, theta, etr_params, p, method): r''' Calculate aggregate tax revenue. .. math:: R_{t} = \sum_{s=E}^{E+S}\sum_{j=0}^{J}\omega_{s,t}\lambda_{j}(T_{j,s,t} + \tau^{p}_{t}w_{t}e_{j,s}n_{j,s,t} - \theta_{j}w_{t} + \tau^{bq}bq_{j,s,t} + \tau^{c}_{s,t}c_{j,s,t} + \tau^{w}_{t}b_{j,s,t}) + \tau^{b}_{t}(Y_{t}-w_{t}L_{t}) - \tau^{b}_{t}\delta^{\tau}_{t}K^{\tau}_{t} Args: r (array_like): the real interest rate w (array_like): the real wage rate b (Numpy array): household savings n (Numpy array): household labor supply bq (Numpy array): household bequests received c (Numpy array): household consumption Y (array_like): aggregate output L (array_like): aggregate labor K (array_like): aggregate capital factor (scalar): factor (scalar): scaling factor converting model units to dollars theta (Numpy array): social security replacement rate for each lifetime income group etr_params (Numpy array): paramters of the effective tax rate functions p (OG-USA Specifications object): model parameters method (str): adjusts calculation dimensions based on 'SS' or 'TPI' Returns: REVENUE (array_like): aggregate tax revenue T_I (array_like): aggregate income tax revenue T_P (array_like): aggregate net payroll tax revenue, revenues minus social security benefits paid T_BQ (array_like): aggregate bequest tax revenue T_W (array_like): aggregate wealth tax revenue T_C (array_like): aggregate consumption tax revenue business_revenue (array_like): aggregate business tax revenue ''' if method == 'SS': I = r * b + w * p.e * n T_I = np.zeros_like(I) T_I = tax.ETR_income(r, w, b, n, factor, p.e, etr_params, p) * I T_P = p.tau_payroll[-1] * w * p.e * n T_P[p.retire[-1]:] -= theta * w T_W = (tax.ETR_wealth(b, p.h_wealth[-1], p.m_wealth[-1], p.p_wealth[-1]) * b) T_BQ = p.tau_bq[-1] * bq T_C = p.tau_c[-1, :, :] * c business_revenue = tax.get_biz_tax(w, Y, L, K, p, method) REVENUE = ((np.transpose(p.omega_SS * p.lambdas) * (T_I + T_P + T_BQ + T_W + T_C)).sum() + business_revenue) elif method == 'TPI': r_array = utils.to_timepath_shape(r) w_array = utils.to_timepath_shape(w) I = r_array * b + w_array * n * p.e T_I = np.zeros_like(I) T_I = tax.ETR_income(r_array, w_array, b, n, factor, p.e, etr_params, p) * I T_P = p.tau_payroll[:p.T].reshape(p.T, 1, 1) * w_array * n * p.e for t in range(T_P.shape[0]): T_P[t, p.retire[t]:, :] -= (theta.reshape(1, p.J) * p.replacement_rate_adjust[t] * w_array[t]) T_W = (tax.ETR_wealth(b, p.h_wealth[:p.T].reshape(p.T, 1, 1), p.m_wealth[:p.T].reshape(p.T, 1, 1), p.p_wealth[:p.T].reshape(p.T, 1, 1)) * b) T_BQ = p.tau_bq[:p.T].reshape(p.T, 1, 1) * bq T_C = p.tau_c[:p.T, :, :] * c business_revenue = tax.get_biz_tax(w, Y, L, K, p, method) REVENUE = ((((np.squeeze(p.lambdas)) * np.tile(np.reshape(p.omega[:p.T, :], (p.T, p.S, 1)), (1, 1, p.J))) * (T_I + T_P + T_BQ + T_W + T_C)).sum(1).sum(1) + business_revenue) return REVENUE, T_I, T_P, T_BQ, T_W, T_C, business_revenue
def revenue(r, w, b, n, bq, c, Y, L, K, factor, theta, etr_params, p, method): ''' Gives lump sum transfer value. Inputs: r = [T,] vector, interest rate w = [T,] vector, wage rate b = [T,S,J] array, wealth holdings n = [T,S,J] array, labor supply BQ = [T,J] array, bequest amounts factor = scalar, model income scaling factor params = length 12 tuple, (e, lambdas, omega, method, etr_params, theta, tau_bq, tau_payroll, h_wealth, p_wealth, m_wealth, retire, T, S, J) e = [T,S,J] array, effective labor units lambdas = [J,] vector, population weights by lifetime income group omega = [T,S] array, population weights by age method = string, 'SS' or 'TPI' etr_params = [T,S,J] array, effective tax rate function parameters tax_func_types = string, type of tax function used theta = [J,] vector, replacement rate values by lifetime income group tau_bq = scalar, bequest tax rate h_wealth = scalar, wealth tax function parameter p_wealth = scalar, wealth tax function parameter m_wealth = scalar, wealth tax function parameter tau_payroll = scalar, payroll tax rate retire = integer, retirement age T = integer, number of periods in transition path S = integer, number of age groups J = integer, number of lifetime income groups Functions called: ETR_income ETR_wealth Objects in function: I = [T,S,J] array, total income T_I = [T,S,J] array, total income taxes T_P = [T,S,J] array, total payroll taxes T_W = [T,S,J] array, total wealth taxes T_BQ = [T,S,J] array, total bequest taxes T_H = [T,] vector, lump sum transfer amount(s) Returns: T_H ''' if method == 'SS': I = r * b + w * p.e * n T_I = np.zeros_like(I) T_I = tax.ETR_income(r, w, b, n, factor, p.e, etr_params, p) * I T_P = p.tau_payroll[-1] * w * p.e * n T_P[p.retire[-1]:] -= theta * w T_W = ( tax.ETR_wealth(b, p.h_wealth[-1], p.m_wealth[-1], p.p_wealth[-1]) * b) T_BQ = p.tau_bq[-1] * bq T_C = p.tau_c[-1, :, :] * c business_revenue = tax.get_biz_tax(w, Y, L, K, p, method) REVENUE = ((np.transpose(p.omega_SS * p.lambdas) * (T_I + T_P + T_BQ + T_W + T_C)).sum() + business_revenue) elif method == 'TPI': r_array = utils.to_timepath_shape(r, p) w_array = utils.to_timepath_shape(w, p) I = r_array * b + w_array * n * p.e T_I = np.zeros_like(I) T_I = tax.ETR_income(r_array, w_array, b, n, factor, p.e, etr_params, p) * I T_P = p.tau_payroll[:p.T].reshape(p.T, 1, 1) * w_array * n * p.e for t in range(T_P.shape[0]): T_P[t, p.retire[t]:, :] -= (theta.reshape(1, p.J) * p.replacement_rate_adjust[t] * w_array[t]) T_W = (tax.ETR_wealth( b, p.h_wealth[:p.T].reshape(p.T, 1, 1), p.m_wealth[:p.T].reshape( p.T, 1, 1), p.p_wealth[:p.T].reshape(p.T, 1, 1)) * b) T_BQ = p.tau_bq[:p.T].reshape(p.T, 1, 1) * bq T_C = p.tau_c[:p.T, :, :] * c business_revenue = tax.get_biz_tax(w, Y, L, K, p, method) REVENUE = ((((np.squeeze(p.lambdas)) * np.tile(np.reshape(p.omega[:p.T, :], (p.T, p.S, 1)), (1, 1, p.J))) * (T_I + T_P + T_BQ + T_W + T_C)).sum(1).sum(1) + business_revenue) return REVENUE, T_I, T_P, T_BQ, T_W, T_C, business_revenue