def test_make_behavioral_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) # create behavioral calculators and vary substitution and income effects behavior1 = {2013: {"_BE_sub": [0.4], "_BE_inc": [0.15]}} behavior_y.update_behavior(behavior1) calc_y_behavior1 = behavior(calc_x, calc_y) behavior2 = {2013: {"_BE_sub": [0.5], "_BE_inc": [0.15]}} behavior_y.update_behavior(behavior2) calc_y_behavior2 = behavior(calc_x, calc_y) behavior3 = {2013: {"_BE_sub": [0.4], "_BE_inc": [0.0]}} behavior_y.update_behavior(behavior3) calc_y_behavior3 = behavior(calc_x, calc_y) # check that total income tax liability differs across the three behaviors assert (calc_y_behavior1.records._iitax.sum() != calc_y_behavior2.records._iitax.sum() != calc_y_behavior3.records._iitax.sum())
def test_make_behavioral_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) # create behavioral calculators and vary substitution and income effects behavior1 = { 2013: { "_BE_sub": [0.4], "_BE_inc": [0.15] } } behavior_y.update_behavior(behavior1) calc_y_behavior1 = behavior(calc_x, calc_y) behavior2 = { 2013: { "_BE_sub": [0.5], "_BE_inc": [0.15] } } behavior_y.update_behavior(behavior2) calc_y_behavior2 = behavior(calc_x, calc_y) behavior3 = { 2013: { "_BE_sub": [0.4], "_BE_inc": [0.0] } } behavior_y.update_behavior(behavior3) calc_y_behavior3 = behavior(calc_x, calc_y) # check that total income tax liability differs across the three behaviors assert (calc_y_behavior1.records._iitax.sum() != calc_y_behavior2.records._iitax.sum() != calc_y_behavior3.records._iitax.sum())
has_behavior = True del reforms_json[this_reform]["value"]["_BE_CG_per"] # implement reforms on policy reform = {start_year: reforms_json.get(this_reform).get("value")} c2.policy.implement_reform(reform) # run the current reform for 4 years this_reform_results = [] for j in range(1, start_year - 2010): output_type = reforms_json.get(this_reform).get("output_type") c1.calc_all() baseline = getattr(c1.records, output_type) if has_behavior: c2_behavior = behavior(c1, c2) diff = getattr(c2_behavior.records, output_type) - baseline else: c2.calc_all() diff = getattr(c2.records, output_type) - baseline weighted_sum_diff = (diff * c1.records.s006).sum() / 1000000000 this_reform_results.append(weighted_sum_diff) c1.increment_year() c2.increment_year() # put this reform results in the dictionary for final results results[reforms_json.get(this_reform).get("name")] = this_reform_results