示例#1
0
def test_get_y():
    '''
    Test of household.get_y() function.
    '''
    r_hh = np.array([0.05, 0.04, 0.09])
    w = np.array([1.2, 0.8, 2.5])
    b_s = np.array([0.5, 0.99, 9])
    n = np.array([0.8, 3.2, 0.2])
    expected_y = np.array([0.9754, 3.8796, 0.91])
    p = Specifications()
    # p.update_specifications({'S': 4, 'J': 1})
    p.S = 3
    p.e = np.array([0.99, 1.5, 0.2])

    test_y = household.get_y(r_hh, w, b_s, n, p)

    assert np.allclose(test_y, expected_y)
示例#2
0
r = 0.067 + (0.086 - 0.067) * random_state.rand(p.T)
w = 0.866 + (0.927 - 0.866) * random_state.rand(p.T)
b = 6.94 * random_state.rand(p.T * p.S * p.J).reshape(p.T, p.S, p.J)
c = np.ones((p.T, p.S, p.J)) * 2.2
n = (0.191 + (0.503 - 0.191) *
     random_state.rand(p.T * p.S * p.J).reshape(p.T, p.S, p.J))
BQ = (0.032 + (0.055 - 0.032) *
      random_state.rand(p.T * p.S * p.J).reshape(p.T, p.S, p.J))
bq = BQ / p.lambdas.reshape(1, 1, p.J)
Y = 0.561 + (0.602 - 0.561) * random_state.rand(p.T).reshape(p.T)
L = 0.416 + (0.423 - 0.416) * random_state.rand(p.T).reshape(p.T)
K = 0.957 + (1.163 - 0.957) * random_state.rand(p.T).reshape(p.T)
ubi = np.zeros((p.T, p.S, p.J))
factor = 140000.0
# update parameters instance with new values for test
p.e = (0.263 +
       (2.024 - 0.263) * random_state.rand(p.S * p.J).reshape(p.S, p.J))
p.omega = 0.039 * random_state.rand(p.T * p.S * 1).reshape(p.T, p.S)
p.omega = p.omega / p.omega.sum(axis=1).reshape(p.T, 1)
p.omega_SS = p.omega[-1, :]
etr_params = (0.22 * random_state.rand(
    p.T * p.S * p.J * num_tax_params).reshape(p.T, p.S, p.J, num_tax_params))
theta = 0.101 + (0.156 - 0.101) * random_state.rand(p.J)

p3 = Specifications()
new_param_values3 = {
    'T':
    30,
    'S':
    20,
    'J':
    2,
示例#3
0

@pytest.mark.parametrize('b,p,expected', test_data,
                         ids=['constant params', 'vary params'])
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)


p1 = Specifications()
p1.S = 2
p1.J = 1
p1.e = np.array([0.5, 0.45])
p1.tax_func_type = 'DEP'
etr_params1 = np.reshape(np.array([
    [0.001, 0.002, 0.003, 0.0015, 0.8, 0.8, 0.83, -0.14,
    -0.15, 0.15, 0.16, -0.15],
    [0.001, 0.002, 0.003, 0.0015, 0.8, 0.8, 0.83, -0.14,
    -0.15, 0.15, 0.16, -0.15]]), (1, p1.S, 12))

p2 = Specifications()
p2.S = 2
p2.J = 1
p2.e = np.array([0.5, 0.45])
p2.tax_func_type = 'GS'
etr_params2 = np.reshape(np.array([
    [0.396, 0.7, 0.9, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0.396, 0.7, 0.9, 0, 0, 0, 0, 0, 0, 0, 0, 0]]), (1, p2.S, 12))
示例#4
0
             (TR2, None, p2, 'TPI', expected3), (TR2, 1, p2, 'TPI', expected4)]


@pytest.mark.parametrize(
    'TR,j,p,method,expected',
    test_data,
    ids=['SS, all j', 'SS, one j', 'TPI, all j', 'TPI, one j'])
def test_get_tr(TR, j, p, method, expected):
    # Test the get_tr function
    test_value = household.get_tr(TR, j, p, method)
    print('Test value = ', test_value)
    assert np.allclose(test_value, expected)


p1 = Specifications()
p1.e = 0.99
p1.lambdas = np.array([0.25])
p1.g_y = 0.03
r1 = 0.05
w1 = 1.2
b1 = 0.5
b_splus1_1 = 0.55
n1 = 0.8
BQ1 = 0.1
tau_c1 = 0.05
bq1 = BQ1 / p1.lambdas
net_tax1 = 0.02
j1 = None

p2 = Specifications()
p2.e = np.array([0.99, 1.5, 0.2])