Skip to content

Commit

Permalink
Merge pull request #649 from martinholmer/master
Browse files Browse the repository at this point in the history
Revise reforms.py to trap params not used by TaxBrain and add make_reforms.py script
  • Loading branch information
martinholmer committed Mar 17, 2016
2 parents 8f83769 + 98e8761 commit 80ff43c
Show file tree
Hide file tree
Showing 3 changed files with 369 additions and 2 deletions.
111 changes: 111 additions & 0 deletions taxcalc/taxbrain/make_reforms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
"""
Python script that writes to stdout a reform JSON file suitable for
input into the reforms.py script in this directory.
COMMAND-LINE USAGE: python make_reforms.py > ref.json
AND THEN: python reforms.py --filename ref.json
Note that this script is intended for the use of core development team;
it is not useful for conducting any kind of tax policy analysis.
"""
# CODING-STYLE CHECKS:
# pep8 --ignore=E402 make_reforms.py
# pylint --disable=locally-disabled make_reforms.py
# (when importing numpy, add "--extension-pkg-whitelist=numpy" pylint option)

import os
import sys
CUR_PATH = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(CUR_PATH, '..', '..'))
from taxcalc import Policy # pylint: disable=import-error


START_YEAR = 2016 # year of policy reform
SCALE_FACTOR = 1.10 # multiplicative scaling factor for most policy parameters
PARAMS_NOT_SCALED = set(['_ACTC_ChildNum',
'_ID_Charity_crt_Cash',
'_ID_Charity_crt_Asset',
'_ID_BenefitSurtax_Switch'])
FIRST_YEAR = Policy.JSON_START_YEAR
PARAMS_NOT_USED_IN_TAXBRAIN = set(['_ACTC_Income_thd',
'_ALD_Interest_ec',
'_AMT_Child_em',
'_AMT_em_pe',
'_AMT_thd_MarriedS',
'_CDCC_crt',
'_CDCC_ps',
'_CTC_additional',
'_CTC_additional_ps',
'_CTC_additional_prt',
'_DCC_c',
'_EITC_ps_MarriedJ',
'_EITC_InvestIncome_c',
'_ETC_pe_Single',
'_ETC_pe_Married',
'_ETC_pe_Single',
'_FEI_ec_c',
'_ID_Casualty_HC',
'_ID_Charity_HC',
'_ID_InterestPaid_HC',
'_ID_Medical_HC',
'_ID_Miscellaneous_HC',
'_KT_c_Age',
'_LLC_Expense_c'])
SPC = ' '
TAB = '{}{}{}'.format(SPC, SPC, SPC)


def main():
"""
Highest-level logic of make_reforms.py script.
"""
# get current-law-policy parameters for START_YEAR in a Policy object
clp = Policy()
clp.set_year(START_YEAR)

# construct of set of Policy parameter names
policy_param_names = set(getattr(clp, '_vals').keys())

# remove names of policy parameters not currently used in TaxBrain
param_names = policy_param_names - PARAMS_NOT_USED_IN_TAXBRAIN

# write a JSON entry for each parameter
sys.stdout.write('{}\n'.format('{'))
sys.stdout.write('{}"1": {}\n'.format(SPC, '{'))
sys.stdout.write('{}{}"replications": 1,\n'.format(SPC, SPC))
sys.stdout.write('{}{}"start_year": {},\n'.format(SPC, SPC, START_YEAR))
sys.stdout.write('{}{}"specification": {}\n'.format(SPC, SPC, '{'))
idx = START_YEAR - FIRST_YEAR
num_names = len(param_names)
num = 0
for name in param_names:
num += 1
values = getattr(clp, name)
value = values[idx]
sys.stdout.write('{}"{}": {}\n'.format(TAB, name, '{'))
if isinstance(value, float):
if name in PARAMS_NOT_SCALED:
val = value
else:
val = value * SCALE_FACTOR
else:
if name in PARAMS_NOT_SCALED:
val = value.tolist()
else:
val = [v * SCALE_FACTOR for v in value.tolist()]
sys.stdout.write('{}{}"{}": [{}]\n'.format(TAB, SPC, START_YEAR, val))
if num == num_names:
sys.stdout.write('{}{}\n'.format(TAB, '}'))
else:
sys.stdout.write('{}{}\n'.format(TAB, '},'))
sys.stdout.write('{}{}{}\n'.format(SPC, SPC, '}'))
sys.stdout.write('{}{}\n'.format(SPC, '}'))
sys.stdout.write('{}\n'.format('}'))

# return no-error exit code
return 0
# end of main function code


if __name__ == '__main__':
sys.exit(main())
239 changes: 239 additions & 0 deletions taxcalc/taxbrain/ref.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
{
"1": {
"replications": 1,
"start_year": 2016,
"specification": {
"_SS_percentage2": {
"2016": [0.935]
},
"_SS_percentage1": {
"2016": [0.55]
},
"_EITC_rt": {
"2016": [[0.08415, 0.37400000000000005, 0.44000000000000006, 0.49500000000000005]]
},
"_CTC_c": {
"2016": [1100.0]
},
"_ID_ps": {
"2016": [[285340.0, 342430.0, 171215.0, 313885.0, 342430.0, 171215.0]]
},
"_NIIT_thd": {
"2016": [[220000.00000000003, 275000.0, 137500.0, 220000.00000000003, 275000.0, 137500.0]]
},
"_CTC_prt": {
"2016": [0.055]
},
"_II_rt1": {
"2016": [0.11]
},
"_FICA_mc_trt": {
"2016": [0.0319]
},
"_II_rt3": {
"2016": [0.275]
},
"_ID_BenefitSurtax_trt": {
"2016": [1.1]
},
"_ID_prt": {
"2016": [0.033]
},
"_ALD_SelfEmploymentTax_HC": {
"2016": [0.0]
},
"_II_rt7": {
"2016": [0.4356]
},
"_SS_Earnings_c": {
"2016": [130350.0]
},
"_ID_BenefitSurtax_crt": {
"2016": [1.1]
},
"_ID_Miscellaneous_frt": {
"2016": [0.022]
},
"_ALD_SelfEmp_HealthIns_HC": {
"2016": [0.0]
},
"_CTC_ps": {
"2016": [[82500.0, 121000.00000000001, 60500.00000000001, 82500.0, 82500.0, 60500.00000000001]]
},
"_AMT_trt1": {
"2016": [0.286]
},
"_SS_thd50": {
"2016": [[27500.000000000004, 35200.0, 0.0, 27500.000000000004, 27500.000000000004, 0.0]]
},
"_STD": {
"2016": [[6930.000000000001, 13860.000000000002, 6930.000000000001, 10230.0, 13860.000000000002, 6930.000000000001, 1155.0]]
},
"_II_rt6": {
"2016": [0.385]
},
"_AMT_CG_thd2": {
"2016": [[456555.00000000006, 513645.00000000006, 256822.50000000003, 485100.00000000006, 513645.00000000006, 256822.50000000003]]
},
"_CG_rt1": {
"2016": [0.0]
},
"_CG_rt3": {
"2016": [0.22]
},
"_CG_rt2": {
"2016": [0.165]
},
"_II_brk2": {
"2016": [[41415.0, 82830.0, 41415.0, 55440.00000000001, 82830.0, 41415.0]]
},
"_ID_Charity_crt_Asset": {
"2016": [0.3]
},
"_AMT_CG_thd1": {
"2016": [[41415.0, 82830.0, 41415.0, 55440.00000000001, 82830.0, 41415.0]]
},
"_ALD_EarlyWithdraw_HC": {
"2016": [0.0]
},
"_ID_BenefitSurtax_Switch": {
"2016": [[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
},
"_ID_Charity_frt": {
"2016": [0.0]
},
"_II_rt2": {
"2016": [0.165]
},
"_ALD_Alimony_HC": {
"2016": [0.0]
},
"_ID_StateLocalTax_HC": {
"2016": [0.0]
},
"_AMT_CG_rt3": {
"2016": [0.22]
},
"_II_credit": {
"2016": [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]
},
"_ID_Casualty_frt": {
"2016": [0.11]
},
"_AMT_em": {
"2016": [[59290.00000000001, 92180.00000000001, 46090.00000000001, 59290.00000000001, 92180.00000000001, 46090.00000000001]]
},
"_II_credit_prt": {
"2016": [0.0]
},
"_II_em_ps": {
"2016": [[285340.0, 342430.0, 171215.0, 313885.0, 342430.0, 171215.0]]
},
"_II_em": {
"2016": [4455.0]
},
"_AMED_thd": {
"2016": [[220000.00000000003, 275000.0, 137500.0, 220000.00000000003, 220000.00000000003, 137500.0]]
},
"_FICA_ss_trt": {
"2016": [0.1364]
},
"_AMT_tthd": {
"2016": [204930.0]
},
"_EITC_c": {
"2016": [[556.6, 3710.3, 6129.200000000001, 6895.900000000001]]
},
"_II_rt5": {
"2016": [0.363]
},
"_STD_Aged": {
"2016": [[1705.0000000000002, 1375.0, 1375.0, 1705.0000000000002, 1705.0000000000002, 1375.0]]
},
"_AMT_prt": {
"2016": [0.275]
},
"_II_brk4": {
"2016": [[209165.00000000003, 254595.00000000003, 127297.50000000001, 231880.00000000003, 254595.00000000003, 127297.50000000001]]
},
"_NIIT_trt": {
"2016": [0.0418]
},
"_ID_crt": {
"2016": [0.88]
},
"_II_prt": {
"2016": [0.022]
},
"_AMT_CG_rt1": {
"2016": [0.0]
},
"_EITC_prt": {
"2016": [[0.08415, 0.17578000000000002, 0.23166000000000003, 0.23166000000000003]]
},
"_CG_thd1": {
"2016": [[41415.0, 82830.0, 41415.0, 55440.00000000001, 82830.0, 41415.0]]
},
"_CG_thd2": {
"2016": [[456555.00000000006, 513645.00000000006, 256822.50000000003, 485100.00000000006, 513645.00000000006, 256822.50000000003]]
},
"_AMT_CG_rt2": {
"2016": [0.165]
},
"_ACTC_rt": {
"2016": [0.165]
},
"_AMT_em_ps": {
"2016": [[131670.0, 175670.0, 87835.0, 131670.0, 175670.0, 87835.0]]
},
"_II_credit_ps": {
"2016": [[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]
},
"_ALD_KEOGH_SEP_HC": {
"2016": [0.0]
},
"_ID_RealEstate_HC": {
"2016": [0.0]
},
"_ACTC_ChildNum": {
"2016": [3.0]
},
"_SS_thd85": {
"2016": [[37400.0, 48400.00000000001, 0.0, 37400.0, 37400.0, 0.0]]
},
"_ID_Charity_crt_Cash": {
"2016": [0.5]
},
"_AMT_trt2": {
"2016": [0.022]
},
"_AMED_trt": {
"2016": [0.0099]
},
"_II_brk3": {
"2016": [[100265.00000000001, 167090.0, 83545.0, 143165.0, 167090.0, 83545.0]]
},
"_ID_Medical_frt": {
"2016": [0.11]
},
"_II_brk5": {
"2016": [[454685.00000000006, 454685.00000000006, 227342.50000000003, 454685.00000000006, 454685.00000000006, 227342.50000000003]]
},
"_ALD_StudentLoan_HC": {
"2016": [0.0]
},
"_II_brk6": {
"2016": [[456555.00000000006, 513645.00000000006, 256822.50000000003, 485100.00000000006, 513645.00000000006, 256822.50000000003]]
},
"_II_brk1": {
"2016": [[10202.5, 20405.0, 10202.5, 14575.000000000002, 20405.0, 10202.5]]
},
"_EITC_ps": {
"2016": [[9097.0, 20009.0, 20009.0, 20009.0]]
},
"_II_rt4": {
"2016": [0.308]
}
}
}
}

0 comments on commit 80ff43c

Please sign in to comment.