Skip to content

Commit

Permalink
Merge pull request #2169 from martinholmer/itexp-validation
Browse files Browse the repository at this point in the history
Add assumption set c to taxsim_input.py
  • Loading branch information
martinholmer authored Dec 12, 2018
2 parents f5b668c + 50b7940 commit 7c39274
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 16 deletions.
10 changes: 5 additions & 5 deletions taxcalc/calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,15 +1117,15 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
"""
Calculates Form 2441 child and dependent care expense credit, c07180.
"""
# credit for at most two cared-for individuals and for actual expenses
max_credit = min(f2441, 2) * CDCC_c
c32800 = max(0., min(e32800, max_credit))
# credit is limited to minimum of individuals' earned income
c32880 = earned_p # earned income of taxpayer
if MARS == 2:
c32890 = earned_s # earned income of spouse, if present
c32890 = earned_s # earned income of spouse when present
else:
c32890 = earned_p
dclim = min(f2441, 2) * CDCC_c
# care expenses are limited by policy
c32800 = max(0., min(e32800, dclim))
# credit is limited to minimum of individuals' earned income
c33000 = max(0., min(c32800, min(c32880, c32890)))
# credit is limited by AGI-related fraction
if exact == 1: # exact calculation as on tax forms
Expand Down
4 changes: 4 additions & 0 deletions taxcalc/validation/taxsim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ federal income tax or because they specify rent paid that does not
affect federal income tax liability. Three of the remaining four
input variables are itemized expense amounts and the fourth is
child-care expenses. (This is the b17 assumption set.)

**2018-12-12** : Same results for a 2017 INPUT file that specifies all
the non-state TAXSIM-27 input variables to be randomly generated
values. (This is the c17 assumption set.)
10 changes: 10 additions & 0 deletions taxcalc/validation/taxsim/c17.taxdiffs-expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 9 109 0 0.90 [88]
TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 16 7409 0 -23986.50 [29904]
TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 17 28 0 71000.00 [17757]
TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 18 28 0 -49350.00 [14030]
TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 22 23 0 -3405.00 [14083]
TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 24 19 0 -935.00 [89283]
TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 26 28 0 -40000.00 [17757]
TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 27 1674 1674 -0.01 [21806]
TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 28 2593 2565 -3405.00 [14083]
TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 4 1053 1053 -0.01 [20]
Binary file modified taxcalc/validation/taxsim/output-taxsim.zip
Binary file not shown.
12 changes: 12 additions & 0 deletions taxcalc/validation/taxsim/taxcalc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,24 @@ fi
L=${LYY_FN:0:1}
YY=${LYY_FN:1:2}
python prepare_taxcalc_input.py $LYY_FN $LYY_FN.csv
if [[ $? -ne 0 ]]; then
echo "ERROR: prepare_taxcalc_input.py failed"
exit 1
fi
# ... calculate Tax-Calculator output
tc $LYY_FN.csv 20$YY --reform taxsim_emulation.json --dump
if [[ $? -ne 0 ]]; then
echo "ERROR: taxcalc package is not available"
exit 1
fi
mv $LYY_FN-$YY-#-taxsim_emulation-#.csv $LYY_FN.out.csv
rm -f $LYY_FN-$YY-#-taxsim_emulation-#-doc.text
# ... convert Tax-Calculator output to Internet-TAXSIM-27-format
python process_taxcalc_output.py $LYY_FN.out.csv $LYY_FN.out-taxcalc
if [[ $? -ne 0 ]]; then
echo "ERROR: process_taxcalc_output.py failed"
exit 1
fi
# ... delete intermediate input and output files if not saving files
if [[ $SAVE == false ]]; then
rm -f $LYY_FN.csv
Expand Down
8 changes: 7 additions & 1 deletion taxcalc/validation/taxsim/taxsim_emulation.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
// income takes a filing unit above the ceiling.
// (This change was introduced for assumption set b and higher.)
//
// (5) _AMT_CG_brk2 for MARS=4 = 444500 (rather than 444550)
// This seems to be a typo in TAXSIM-27 source code.
// (This change was introduced for assumption set c and higher.)
//
{
"policy": {

Expand All @@ -44,7 +48,9 @@

"_AMT_child_em_c_age": {"2013": [24]},

"_EITC_excess_InvestIncome_rt": {"2013": [1.0]}
"_EITC_excess_InvestIncome_rt": {"2013": [1.0]},

"_AMT_CG_brk2": {"2017": [[418400, 470700, 235350, 444500, 470700]]}

}
}
14 changes: 7 additions & 7 deletions taxcalc/validation/taxsim/taxsim_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,14 @@ def assumption_set(year, letter):
adict['max_pnben'] = 0 # TAXSIM ivar 19
adict['max_ssben'] = 0 # TAXSIM ivar 20
adict['max_uiben'] = 0 # TAXSIM ivar 21
# itemized and childcare expense amounts (all zero):
# childcare expense amount (all zero):
adict['max_ccexp'] = 0 # TAXSIM ivar 26
# itemized expense amounts (all zero):
adict['max_ided_proptax'] = 0 # TAXSIM ivar 24
adict['max_ided_nopref'] = 0 # TAXSIM ivar 25
adict['max_ccexp'] = 0 # TAXSIM ivar 26
adict['max_ided_mortgage'] = 0 # TAXSIM ivar 27
# end if letter in VALID_LETTERS
if letter == 'b': # <=====================================================
if letter in ['b', 'c']: # <==============================================
# non-labor income:
adict['max_divinc'] = 20 # TAXSIM ivar 13
adict['max_intinc'] = 20 # TAXSIM ivar 14
Expand All @@ -132,10 +133,9 @@ def assumption_set(year, letter):
# childcare expense amount:
adict['max_ccexp'] = 10 # TAXSIM ivar 26
# itemized expense amounts:
# adict['max_ided_proptax'] = 0 # TAXSIM ivar 24
# adict['max_ided_nopref'] = 0 # TAXSIM ivar 25
# adict['max_ccexp'] = 15 # TAXSIM ivar 26
# adict['max_ided_mortgage'] = 0 # TAXSIM ivar 27
adict['max_ided_proptax'] = 30 # TAXSIM ivar 24
adict['max_ided_nopref'] = 10 # TAXSIM ivar 25
adict['max_ided_mortgage'] = 40 # TAXSIM ivar 27
return adict


Expand Down
14 changes: 11 additions & 3 deletions taxcalc/validation/taxsim/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,24 @@ fi
L=${LYY:0:1}
YY=${LYY:1:2}
python taxsim_input.py 20$YY $L > $LYY.in
if [[ $? -ne 0 ]]; then
echo "ERROR: taxsim_input.py failed"
exit 1
fi
# (2) generate TAXSIM-27-formatted output using Tax-Calculator tc CLI
./taxcalc.sh $LYY.in $SAVE
if [[ $? -ne 0 ]]; then
echo "ERROR: taxcalc.sh failed"
exit 1
fi
# (3) generate tax differences
# ... unzip TAXSIM-27 OUTPUT for specified INPUT
unzip -oq output-taxsim.zip $LYY.in.out-taxsim
# ... compare Tax-Calculator OUTPUT and TAXSIM-27 OUTPUT files
tclsh taxdiffs.tcl $LYY.in.out-taxcalc $LYY.in.out-taxsim > $LYY.taxdiffs-actual
RC=$?
if [[ $RC -ne 0 ]]; then
exit $RC
if [[ $? -ne 0 ]]; then
echo "ERROR: taxdiffs.tcl failed"
exit 1
fi
# check for difference between LYY.taxdiffs-actual and LYY.taxdiffs-expect
diff --brief $LYY.taxdiffs-actual $LYY.taxdiffs-expect
Expand Down

0 comments on commit 7c39274

Please sign in to comment.