Ejemplo n.º 1
0
def test_behavioral_response_Calculator(cps_subsample):
    # create Records objects
    records_x = Records.cps_constructor(data=cps_subsample)
    records_y = Records.cps_constructor(data=cps_subsample)
    year = records_x.current_year
    # create Policy objects
    policy_x = Policy()
    policy_y = Policy()
    # implement policy_y reform
    reform = {year: {'_II_rt7': [0.496],
                     '_PT_rt7': [0.496]}}
    policy_y.implement_reform(reform)
    # create two Calculator objects
    behavior_y = Behavior()
    calc_x = Calculator(policy=policy_x, records=records_x)
    calc_y = Calculator(policy=policy_y, records=records_y,
                        behavior=behavior_y)
    # test incorrect use of Behavior._mtr_xy method
    with pytest.raises(ValueError):
        behv = Behavior._mtr_xy(calc_x, calc_y,
                                mtr_of='e00200p',
                                tax_type='nonsense')
    # vary substitution and income effects in calc_y
    behavior0 = {year: {'_BE_sub': [0.0],
                        '_BE_cg': [0.0],
                        '_BE_charity': [[0.0, 0.0, 0.0]]}}
    behavior_y.update_behavior(behavior0)
    calc_y_behavior0 = Behavior.response(calc_x, calc_y)
    behavior1 = {year: {'_BE_sub': [0.3], '_BE_inc': [-0.1], '_BE_cg': [0.0],
                        '_BE_subinc_wrt_earnings': [True]}}
    behavior_y.update_behavior(behavior1)
    assert behavior_y.has_response() is True
    epsilon = 1e-9
    assert abs(behavior_y.BE_sub - 0.3) < epsilon
    assert abs(behavior_y.BE_inc - -0.1) < epsilon
    assert abs(behavior_y.BE_cg - 0.0) < epsilon
    calc_y_behavior1 = Behavior.response(calc_x, calc_y)
    behavior2 = {year: {'_BE_sub': [0.5], '_BE_cg': [-0.8]}}
    behavior_y.update_behavior(behavior2)
    calc_y_behavior2 = Behavior.response(calc_x, calc_y)
    behavior3 = {year: {'_BE_inc': [-0.2], '_BE_cg': [-0.8]}}
    behavior_y.update_behavior(behavior3)
    calc_y_behavior3 = Behavior.response(calc_x, calc_y)
    behavior4 = {year: {'_BE_cg': [-0.8]}}
    behavior_y.update_behavior(behavior4)
    calc_y_behavior4 = Behavior.response(calc_x, calc_y)
    behavior5 = {year: {'_BE_charity': [[-0.5, -0.5, -0.5]]}}
    behavior_y.update_behavior(behavior5)
    calc_y_behavior5 = Behavior.response(calc_x, calc_y)
    # check that total income tax liability differs across the
    # six sets of behavioral-response elasticities
    assert (calc_y_behavior0.records.iitax.sum() !=
            calc_y_behavior1.records.iitax.sum() !=
            calc_y_behavior2.records.iitax.sum() !=
            calc_y_behavior3.records.iitax.sum() !=
            calc_y_behavior4.records.iitax.sum() !=
            calc_y_behavior5.records.iitax.sum())
    # test incorrect _mtr_xy() usage
    with pytest.raises(ValueError):
        Behavior._mtr_xy(calc_x, calc_y, mtr_of='e00200p', tax_type='?')
Ejemplo n.º 2
0
def test_behavioral_response_Calculator(puf_1991, weights_1991):
    # create Records objects
    records_x = Records(data=puf_1991, weights=weights_1991, start_year=2009)
    records_y = Records(data=puf_1991, weights=weights_1991, start_year=2009)
    # create Policy objects
    policy_x = Policy()
    policy_y = Policy()
    # implement policy_y reform
    reform = {2013: {'_II_rt7': [0.496],
                     '_PT_rt7': [0.496]}}
    policy_y.implement_reform(reform)
    # create two Calculator objects
    behavior_y = Behavior()
    calc_x = Calculator(policy=policy_x, records=records_x)
    calc_y = Calculator(policy=policy_y, records=records_y,
                        behavior=behavior_y)
    # test incorrect use of Behavior._mtr_xy method
    with pytest.raises(ValueError):
        behv = Behavior._mtr_xy(calc_x, calc_y,
                                mtr_of='e00200p',
                                tax_type='nonsense')
    # vary substitution and income effects in calc_y
    behavior0 = {2013: {'_BE_sub': [0.0],
                        '_BE_cg': [0.0],
                        '_BE_charity': [[0.0, 0.0, 0.0]]}}
    behavior_y.update_behavior(behavior0)
    calc_y_behavior0 = Behavior.response(calc_x, calc_y)
    behavior1 = {2013: {'_BE_sub': [0.3], '_BE_cg': [0.0]}}
    behavior_y.update_behavior(behavior1)
    assert behavior_y.has_response() is True
    assert behavior_y.BE_sub == 0.3
    assert behavior_y.BE_inc == 0.0
    assert behavior_y.BE_cg == 0.0
    calc_y_behavior1 = Behavior.response(calc_x, calc_y)
    behavior2 = {2013: {'_BE_sub': [0.5], '_BE_cg': [-0.8]}}
    behavior_y.update_behavior(behavior2)
    calc_y_behavior2 = Behavior.response(calc_x, calc_y)
    behavior3 = {2013: {'_BE_inc': [-0.2], '_BE_cg': [-0.8]}}
    behavior_y.update_behavior(behavior3)
    calc_y_behavior3 = Behavior.response(calc_x, calc_y)
    behavior4 = {2013: {'_BE_cg': [-0.8]}}
    behavior_y.update_behavior(behavior4)
    calc_y_behavior4 = Behavior.response(calc_x, calc_y)
    behavior5 = {2013: {'_BE_charity': [[-0.5, -0.5, -0.5]]}}
    behavior_y.update_behavior(behavior5)
    calc_y_behavior5 = Behavior.response(calc_x, calc_y)
    # check that total income tax liability differs across the
    # six sets of behavioral-response elasticities
    assert (calc_y_behavior0.records.iitax.sum() !=
            calc_y_behavior1.records.iitax.sum() !=
            calc_y_behavior2.records.iitax.sum() !=
            calc_y_behavior3.records.iitax.sum() !=
            calc_y_behavior4.records.iitax.sum() !=
            calc_y_behavior5.records.iitax.sum())
    # test incorrect _mtr_xy() usage
    with pytest.raises(ValueError):
        Behavior._mtr_xy(calc_x, calc_y, mtr_of='e00200p', tax_type='?')
Ejemplo n.º 3
0
def test_behavioral_response_Calculator(puf_1991, weights_1991):
    # create Records objects
    records_x = Records(data=puf_1991, weights=weights_1991, start_year=2009)
    records_y = Records(data=puf_1991, weights=weights_1991, start_year=2009)
    # create Policy objects
    policy_x = Policy()
    policy_y = Policy()
    # implement policy_y reform
    reform = {2013: {"_II_rt7": [0.496], "_PT_rt7": [0.496]}}
    policy_y.implement_reform(reform)
    # create two Calculator objects
    behavior_y = Behavior()
    calc_x = Calculator(policy=policy_x, records=records_x)
    calc_y = Calculator(policy=policy_y, records=records_y, behavior=behavior_y)
    # test incorrect use of Behavior._mtr_xy method
    with pytest.raises(ValueError):
        behv = Behavior._mtr_xy(calc_x, calc_y, mtr_of="e00200p", tax_type="nonsense")
    # vary substitution and income effects in calc_y
    behavior1 = {2013: {"_BE_sub": [0.3], "_BE_cg": [0.0]}}
    behavior_y.update_behavior(behavior1)
    assert behavior_y.has_response() is True
    assert behavior_y.BE_sub == 0.3
    assert behavior_y.BE_inc == 0.0
    assert behavior_y.BE_cg == 0.0
    calc_y_behavior1 = Behavior.response(calc_x, calc_y)
    behavior2 = {2013: {"_BE_sub": [0.5], "_BE_cg": [-0.8]}}
    behavior_y.update_behavior(behavior2)
    calc_y_behavior2 = Behavior.response(calc_x, calc_y)
    behavior3 = {2013: {"_BE_inc": [-0.2], "_BE_cg": [-0.8]}}
    behavior_y.update_behavior(behavior3)
    calc_y_behavior3 = Behavior.response(calc_x, calc_y)
    behavior4 = {2013: {"_BE_cg": [-0.8]}}
    behavior_y.update_behavior(behavior4)
    calc_y_behavior4 = Behavior.response(calc_x, calc_y)
    # check that total income tax liability differs across the
    # four sets of behavioral-response elasticities
    assert (
        calc_y_behavior1.records._iitax.sum()
        != calc_y_behavior2.records._iitax.sum()
        != calc_y_behavior3.records._iitax.sum()
        != calc_y_behavior4.records._iitax.sum()
    )
    # test incorrect _mtr_xy() usage
    with pytest.raises(ValueError):
        Behavior._mtr_xy(calc_x, calc_y, mtr_of="e00200p", tax_type="?")
def test_behavioral_response_Calculator():
    # create Records objects
    records_x = Records(data=TAXDATA, weights=WEIGHTS, start_year=2009)
    records_y = Records(data=TAXDATA, weights=WEIGHTS, start_year=2009)
    # create Policy objects
    policy_x = Policy()
    policy_y = Policy()
    # implement policy_y reform
    reform = {2013: {'_II_rt7': [0.496]}}
    policy_y.implement_reform(reform)
    # create two Calculator objects
    behavior_y = Behavior()
    calc_x = Calculator(policy=policy_x, records=records_x)
    calc_y = Calculator(policy=policy_y, records=records_y,
                        behavior=behavior_y)
    # test incorrect use of Behavior._mtr_xy method
    with pytest.raises(ValueError):
        behv = Behavior._mtr_xy(calc_x, calc_y,
                                mtr_of='e00200p',
                                tax_type='nonsense')
    # vary substitution and income effects in calc_y
    behavior1 = {2013: {'_BE_sub': [0.4], '_BE_inc': [-0.1]}}
    behavior_y.update_behavior(behavior1)
    assert behavior_y.has_response() is True
    assert behavior_y.BE_sub == 0.4
    assert behavior_y.BE_inc == -0.1
    calc_y_behavior1 = Behavior.response(calc_x, calc_y)
    behavior2 = {2013: {'_BE_sub': [0.5], '_BE_cg': [0.8]}}
    behavior_y.update_behavior(behavior2)
    calc_y_behavior2 = Behavior.response(calc_x, calc_y)
    behavior3 = {2013: {'_BE_inc': [-0.2], '_BE_cg': [0.6]}}
    behavior_y.update_behavior(behavior3)
    calc_y_behavior3 = Behavior.response(calc_x, calc_y)
    # check that total income tax liability differs across the
    # three sets of behavioral-response elasticities
    assert (calc_y_behavior1.records._iitax.sum() !=
            calc_y_behavior2.records._iitax.sum() !=
            calc_y_behavior3.records._iitax.sum())
    # test incorrect _mtr_xy() usage
    with pytest.raises(ValueError):
        Behavior._mtr_xy(calc_x, calc_y, mtr_of='e00200p', tax_type='?')
Ejemplo n.º 5
0
def test_behavioral_response_calculator(cps_subsample):
    # create Records object
    rec = Records.cps_constructor(data=cps_subsample)
    year = rec.current_year
    # create Policy object
    pol = Policy()
    # create current-law Calculator object
    calc1 = Calculator(policy=pol, records=rec)
    # implement policy reform
    reform = {year: {'_II_rt7': [0.496],
                     '_PT_rt7': [0.496]}}
    pol.implement_reform(reform)
    # create reform Calculator object with no behavioral response
    behv = Behavior()
    calc2 = Calculator(policy=pol, records=rec, behavior=behv)
    # test incorrect use of Behavior._mtr_xy method
    with pytest.raises(ValueError):
        Behavior._mtr_xy(calc1, calc2, mtr_of='e00200p', tax_type='nonsense')
    # vary substitution and income effects in Behavior object
    behavior0 = {year: {'_BE_sub': [0.0],
                        '_BE_cg': [0.0],
                        '_BE_charity': [[0.0, 0.0, 0.0]]}}
    behv0 = Behavior()
    behv0.update_behavior(behavior0)
    calc2 = Calculator(policy=pol, records=rec, behavior=behv0)
    assert calc2.behavior.has_response() is False
    calc2_behv0 = Behavior.response(calc1, calc2)
    behavior1 = {year: {'_BE_sub': [0.3], '_BE_inc': [-0.1], '_BE_cg': [0.0],
                        '_BE_subinc_wrt_earnings': [True]}}
    behv1 = Behavior()
    behv1.update_behavior(behavior1)
    calc2 = Calculator(policy=pol, records=rec, behavior=behv1)
    assert calc2.behavior.has_response() is True
    epsilon = 1e-9
    assert abs(calc2.behavior.BE_sub - 0.3) < epsilon
    assert abs(calc2.behavior.BE_inc - -0.1) < epsilon
    assert abs(calc2.behavior.BE_cg - 0.0) < epsilon
    calc2_behv1 = Behavior.response(calc1, calc2)
    behavior2 = {year: {'_BE_sub': [0.5], '_BE_cg': [-0.8]}}
    behv2 = Behavior()
    behv2.update_behavior(behavior2)
    calc2 = Calculator(policy=pol, records=rec, behavior=behv2)
    assert calc2.behavior.has_response() is True
    calc2_behv2 = Behavior.response(calc1, calc2, trace=True)
    behavior3 = {year: {'_BE_inc': [-0.2], '_BE_cg': [-0.8]}}
    behv3 = Behavior()
    behv3.update_behavior(behavior3)
    calc2 = Calculator(policy=pol, records=rec, behavior=behv3)
    assert calc2.behavior.has_response() is True
    calc2_behv3 = Behavior.response(calc1, calc2)
    behavior4 = {year: {'_BE_cg': [-0.8]}}
    behv4 = Behavior()
    behv4.update_behavior(behavior4)
    calc2 = Calculator(policy=pol, records=rec, behavior=behv4)
    assert calc2.behavior.has_response() is True
    calc2_behv4 = Behavior.response(calc1, calc2)
    behavior5 = {year: {'_BE_charity': [[-0.5, -0.5, -0.5]]}}
    behv5 = Behavior()
    behv5.update_behavior(behavior5)
    calc2 = Calculator(policy=pol, records=rec, behavior=behv5)
    assert calc2.behavior.has_response() is True
    calc2_behv5 = Behavior.response(calc1, calc2)
    # check that total income tax liability differs across the
    # six sets of behavioral-response elasticities
    assert (calc2_behv0.records.iitax.sum() !=
            calc2_behv1.records.iitax.sum() !=
            calc2_behv2.records.iitax.sum() !=
            calc2_behv3.records.iitax.sum() !=
            calc2_behv4.records.iitax.sum() !=
            calc2_behv5.records.iitax.sum())