Skip to content

Commit

Permalink
Merge pull request #1 from jdebacker/ARPApolicy
Browse files Browse the repository at this point in the history
Update PUF expected results
  • Loading branch information
amshoulders committed May 11, 2021
2 parents 4eeca95 + 26f3530 commit c2b201f
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 287 deletions.
2 changes: 1 addition & 1 deletion taxcalc/tests/cpscsv_agg_expect.csv
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ With Income Tax <= 0 (#m),92.2,96.8,97.4,101.3,136.3,102.4,103.1,103.7,104.2,101
With Combined Tax <= 0 (#m),63.7,66.3,67.2,69.4,106.3,71.7,72.6,73.5,74.5,73.7
UBI Benefits ($b),0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"Total Benefits, Consumption Value ($b)",3061.5,3253.0,3458.2,3650.1,3871.6,4112.5,4372.9,4645.2,4929.2,5219.0
Total Benefits Cost ($b),3061.5,3253.0,3458.2,3650.1,3871.6,4112.5,4372.9,4645.2,4929.2,5219.0
Total Benefits Cost ($b),3061.5,3253.0,3458.2,3650.1,3871.6,4112.5,4372.9,4645.2,4929.2,5219.0
16 changes: 8 additions & 8 deletions taxcalc/tests/puf_var_wght_means_by_year.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
,description,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030
c00100,Federal AGI, 57146, 61263, 63408, 63408, 66570, 69275, 71469, 69070, 69479, 71637, 73576, 75917, 78467, 81207, 84023, 86753, 89324, 91925
c02500,OASDI benefits in AGI, 1449, 1557, 1661, 1700, 1798, 1909, 2035, 2120, 2169, 2314, 2476, 2654, 2846, 3050, 3268, 3506, 3757, 4024
c04470,Post-phase-out itemized deduction, 6617, 6762, 7085, 7282, 7562, 7885, 8163, 8382, 7930, 8150, 8424, 8733, 9085, 9456, 9840, 10252, 10671, 11091
c04470,Post-phase-out itemized deduction, 6617, 6762, 7085, 7282, 7562, 7885, 8163, 8376, 7930, 8150, 8424, 8733, 9085, 9456, 9840, 10252, 10671, 11091
c04600,Post-phase-out personal exemption, 7299, 7322, 7374, 7426, 7373, 7486, 7635, 7761, 7810, 7875, 7992, 8139, 8294, 8452, 8607, 8769, 8937, 9110
c04800,Federal regular taxable income, 40087, 44105, 45811, 45617, 48513, 50731, 52442, 49642, 50419, 52249, 53725, 55544, 57539, 59664, 61852, 63918, 65813, 67727
c05200,Regular tax on taxable income, 8601, 9801, 10188, 10058, 10884, 11453, 11854, 11079, 11235, 11672, 11992, 12408, 12873, 13365, 13874, 14345, 14772, 15203
c07180,Child care credit, 18, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18
c07220,Child tax credit (adjusted), 174, 170, 166, 162, 159, 153, 149, 142, 141, 139, 135, 132, 128, 125, 121, 118, 115, 112
c04800,Federal regular taxable income, 40087, 44105, 45811, 45617, 48513, 50731, 52442, 49583, 50419, 52249, 53725, 55544, 57539, 59664, 61852, 63918, 65813, 67727
c05200,Regular tax on taxable income, 8601, 9801, 10188, 10058, 10884, 11453, 11854, 11071, 11235, 11672, 11992, 12408, 12873, 13365, 13874, 14345, 14772, 15203
c07180,Child care credit, 18, 19, 19, 19, 19, 19, 19, 18, 0, 18, 18, 18, 18, 18, 18, 18, 18, 18
c07220,Child tax credit (adjusted), 174, 170, 166, 162, 159, 153, 149, 141, 315, 139, 135, 132, 128, 125, 121, 118, 115, 112
c09600,Federal AMT liability, 237, 253, 268, 274, 294, 311, 323, 331, 309, 316, 327, 338, 352, 368, 386, 405, 424, 443
c11070,Extra child tax credit (refunded), 164, 159, 154, 150, 145, 141, 138, 144, 139, 135, 132, 130, 127, 124, 121, 118, 117, 115
c11070,Extra child tax credit (refunded), 164, 159, 154, 150, 145, 141, 138, 145, 0, 135, 132, 130, 127, 124, 121, 118, 117, 115
c21040,Itemized deduction that is phased out, 228, 272, 283, 276, 304, 322, 333, 311, 310, 322, 332, 344, 359, 373, 388, 402, 414, 427
cmbtp,Estimate of income on (AMT) Form 6251 but not in AGI, 414, 432, 452, 461, 481, 503, 521, 535, 516, 527, 545, 562, 583, 608, 634, 660, 685, 710
data_source,1 if unit is created primarily from IRS-SOI PUF data; 0 if created primarily from CPS data (not used in tax-calculation logic), 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Expand Down Expand Up @@ -64,10 +64,10 @@ e58990,Investment income elected amount from Form 4952, 15, 16, 1
e62900,Alternative Minimum Tax foreign tax credit from Form 6251, 88, 97, 100, 101, 105, 109, 112, 114, 109, 112, 115, 118, 121, 126, 130, 135, 140, 144
e87521,Total tentative AmOppCredit amount for all students, 193, 197, 204, 207, 216, 225, 231, 235, 225, 230, 236, 243, 251, 259, 268, 279, 289, 299
e87530,Adjusted qualified lifetime learning expenses for all students, 104, 104, 108, 109, 114, 119, 123, 125, 120, 122, 125, 129, 133, 138, 143, 148, 153, 159
eitc,Federal EITC, 411, 407, 404, 397, 390, 390, 392, 414, 411, 405, 405, 407, 409, 411, 412, 415, 420, 425
eitc,Federal EITC, 411, 407, 404, 397, 390, 390, 392, 414, 427, 405, 405, 407, 409, 411, 413, 415, 420, 425
elderly_dependents,number of dependents age 65+ in filing unit excluding taxpayer and spouse, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
g20500,Itemizable gross (before 10% AGI disregard) casualty or theft loss, 31, 32, 34, 35, 37, 38, 40, 40, 39, 40, 41, 42, 44, 45, 47, 48, 50, 53
iitax,Federal income tax liability, 7359, 8402, 8794, 8763, 9433, 9955, 10328, 9580, 9768, 10225, 10573, 10998, 11470, 11966, 12475, 12948, 13369, 13794
iitax,Federal income tax liability, 7359, 8402, 8794, 8763, 9433, 9955, 10328, 9572, 7395, 10225, 10572, 10998, 11469, 11965, 12475, 12947, 13369, 13794
k1bx14p,Partner self-employment earnings/loss for taxpayer (included in e26270 total), -243, -269, -269, -254, -244, -247, -242, -232, -241, -258, -274, -292, -313, -323, -334, -336, -334, -332
k1bx14s,Partner self-employment earnings/loss for spouse (included in e26270 total), -9, -9, -9, -7, -6, -6, -5, -5, -5, -5, -6, -5, -6, -6, -7, -6, -5, -3
nu06,Number of dependents under 6 years old, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Expand Down
30 changes: 15 additions & 15 deletions taxcalc/tests/pufcsv_agg_expect.csv
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026
Returns (#m),169.9,172.7,175.2,177.5,179.8,182.0,184.3,186.4,188.7,190.9
AGI ($b),11313.0,12036.9,12586.7,12320.7,12552.8,13103.6,13627.7,14227.7,14889.8,15505.7
AGI ($b),11313.0,12036.9,12586.7,12320.7,12552.8,13103.6,13627.7,14227.7,14889.8,15589.9
Itemizers (#m),46.2,20.8,21.8,21.8,20.8,21.5,22.1,22.7,23.4,53.8
Itemized Deduction ($b),1306.5,653.5,691.3,714.2,667.2,698.9,734.3,770.7,813.0,1840.4
Itemized Deduction ($b),1306.5,653.5,691.3,713.7,667.2,698.9,734.3,770.7,813.0,1840.0
Standard Deduction Filers (#m),123.7,152.0,153.4,155.7,159.0,160.5,162.1,163.7,165.3,137.1
Standard Deduction ($b),1096.2,2579.0,2651.8,2754.6,2815.1,2870.3,2946.5,3033.3,3126.0,1421.1
Standard Deduction ($b),1096.2,2579.0,2651.8,2754.9,2815.1,2870.3,2946.5,3033.3,3126.0,1421.1
Personal Exemption ($b),1253.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1576.8
Taxable Income ($b),8228.7,9296.8,9761.6,9409.6,9640.2,10111.8,10535.8,11026.7,11572.4,11421.1
Regular Tax ($b),1679.9,1733.3,1822.0,1733.2,1782.3,1882.6,1968.8,2069.6,2181.9,2375.4
AMT Income ($b),10708.6,11605.2,12127.5,11842.9,12110.6,12637.9,13135.8,13708.2,14338.2,14645.4
AMT Liability ($b),50.1,22.9,24.2,25.2,24.5,25.2,26.3,27.5,28.9,71.5
Taxable Income ($b),8228.7,9296.8,9761.6,9398.7,9640.2,10111.8,10535.8,11026.7,11572.4,11464.7
Regular Tax ($b),1679.9,1733.3,1822.0,1731.8,1782.3,1882.6,1968.8,2069.6,2181.9,2387.3
AMT Income ($b),10708.6,11605.2,12127.5,11843.2,12110.6,12637.9,13135.8,13708.2,14338.2,14729.6
AMT Liability ($b),50.1,22.9,24.2,25.2,24.5,25.2,26.3,27.5,28.9,73.4
AMT Filers (#m),5.4,0.5,1.2,1.2,1.2,1.2,1.2,1.2,1.2,7.2
Tax before Credits ($b),1730.1,1756.2,1846.2,1758.5,1806.8,1907.8,1995.1,2097.1,2210.8,2446.8
Refundable Credits ($b),104.6,120.0,121.0,127.2,126.0,126.3,127.0,128.1,130.1,114.5
Nonrefundable Credits ($b),67.4,126.7,128.2,125.2,126.8,130.3,133.2,136.6,139.6,76.3
Tax before Credits ($b),1730.1,1756.2,1846.2,1757.0,1806.8,1907.8,1995.1,2097.1,2210.8,2460.7
Refundable Credits ($b),104.6,120.0,121.0,127.3,725.8,126.6,127.4,128.4,130.4,114.9
Nonrefundable Credits ($b),67.4,126.7,128.2,124.9,48.1,130.3,133.2,136.6,139.6,76.3
Reform Surtaxes ($b),0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
Other Taxes ($b),42.1,47.5,50.4,49.2,47.6,48.3,48.8,49.9,51.7,52.3
Ind Income Tax ($b),1600.1,1557.0,1647.4,1555.3,1601.6,1699.5,1783.7,1882.3,1992.7,2308.3
Other Taxes ($b),42.1,47.5,50.4,49.2,47.6,48.3,48.8,49.9,51.7,53.6
Ind Income Tax ($b),1600.1,1557.0,1647.4,1554.0,1080.5,1699.2,1783.4,1882.0,1992.4,2323.2
Payroll Taxes ($b),1110.4,1160.6,1214.4,1191.6,1217.1,1269.9,1322.4,1378.3,1439.2,1504.9
Combined Liability ($b),2710.5,2717.6,2861.8,2746.9,2818.8,2969.4,3106.1,3260.6,3432.0,3813.2
With Income Tax <= 0 (#m),69.2,75.4,75.4,78.8,79.2,79.1,79.2,79.4,79.7,74.1
With Combined Tax <= 0 (#m),40.4,42.1,42.7,44.4,45.2,45.5,45.9,46.6,47.0,45.6
Combined Liability ($b),2710.5,2717.6,2861.8,2745.7,2297.7,2969.1,3105.8,3260.3,3431.6,3828.0
With Income Tax <= 0 (#m),69.2,75.4,75.4,79.0,108.8,79.1,79.2,79.5,79.7,74.1
With Combined Tax <= 0 (#m),40.4,42.1,42.7,44.5,75.9,45.5,45.9,46.7,47.1,45.6
UBI Benefits ($b),0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
"Total Benefits, Consumption Value ($b)",907.9,950.8,1007.9,1066.2,1132.5,1206.8,1288.9,1371.9,1457.6,1546.8
Total Benefits Cost ($b),907.9,950.8,1007.9,1066.2,1132.5,1206.8,1288.9,1371.9,1457.6,1546.8
90 changes: 90 additions & 0 deletions taxcalc/tests/test_calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,93 @@ def test_StdDed(test_tuple, expected_value, skip_jit):
test_value = calcfunctions.StdDed(*test_tuple)

assert np.allclose(test_value, expected_value)


def test_AfterTaxIncome(skip_jit):
'''
Tests the AfterTaxIncome function
'''
test_tuple = (1000, 5000, 4000)
test_value = calcfunctions.AfterTaxIncome(*test_tuple)
expected_value = 4000
assert np.allclose(test_value, expected_value)


def test_ExpandIncome(skip_jit):
'''
Tests the ExpandIncome function
'''
test_tuple = (10000, 1000, 500, 100, 200, 300, 400, 20, 500, 50, 250, 10,
20, 30, 40, 60, 70, 80, 1500, 2000, 16380)
test_value = calcfunctions.ExpandIncome(*test_tuple)
expected_value = 16380
assert np.allclose(test_value, expected_value)


tuple1 = (1, 1, 2, 0, 0, 1000)
tuple2 = (0, 1, 2, 0, 0, 1000)
tuple3 = (1, 1, 2, 100, 0, 1000)
tuple4 = (0, 2, 1, 100, 200, 1000)
tuple5 = (0, 1, 3, 100, 300, 1000)
expected1 = (0, 1000)
expected2 = (0, 1000)
expected3 = (0, 1000)
expected4 = (200, 1200)
expected5 = (300, 1300)


@pytest.mark.parametrize(
'test_tuple,expected_value', [
(tuple1, expected1), (tuple2, expected2), (tuple3, expected3),
(tuple4, expected4), (tuple5, expected5)])
def test_LumpSumTax(test_tuple, expected_value, skip_jit):
'''
Tests LumpSumTax function
'''
test_value = calcfunctions.LumpSumTax(*test_tuple)
assert np.allclose(test_value, expected_value)


FST_AGI_thd_lo_in = [1000000, 1000000, 500000, 1000000, 1000000]
FST_AGI_thd_hi_in = [2000000, 2000000, 1000000, 2000000, 2000000]
tuple1 = (1100000, 1, 1000, 100, 100, 0.1, FST_AGI_thd_lo_in,
FST_AGI_thd_hi_in, 100, 200, 2000, 300)
tuple2 = (2100000, 1, 1000, 100, 100, 0.1, FST_AGI_thd_lo_in,
FST_AGI_thd_hi_in, 100, 200, 2000, 300)
tuple3 = (1100000, 1, 1000, 100, 100, 0, FST_AGI_thd_lo_in,
FST_AGI_thd_hi_in, 100, 200, 2000, 300)
tuple4 = (1100000, 2, 1000, 100, 100, 0.1, FST_AGI_thd_lo_in,
FST_AGI_thd_hi_in, 100, 200, 2000, 300)
tuple5 = (2100000, 2, 1000, 100, 100, 0.1, FST_AGI_thd_lo_in,
FST_AGI_thd_hi_in, 100, 200, 2000, 300)
tuple6 = (1100000, 2, 1000, 100, 100, 0, FST_AGI_thd_lo_in,
FST_AGI_thd_hi_in, 100, 200, 2000, 300)
tuple7 = (510000, 3, 1000, 100, 100, 0.1, FST_AGI_thd_lo_in,
FST_AGI_thd_hi_in, 100, 200, 2000, 300)
tuple8 = (1100000, 3, 1000, 100, 100, 0.1, FST_AGI_thd_lo_in,
FST_AGI_thd_hi_in, 100, 200, 2000, 300)
tuple9 = (510000, 3, 1000, 100, 100, 0, FST_AGI_thd_lo_in,
FST_AGI_thd_hi_in, 100, 200, 2000, 300)
expected1 = (10915, 11115, 12915, 11215)
expected2 = (209150, 209350, 211150, 209450)
expected3 = (0, 200, 2000, 300)
expected4 = (10915, 11115, 12915, 11215)
expected5 = (209150, 209350, 211150, 209450)
expected6 = (0, 200, 2000, 300)
expected7 = (1003, 1203, 3003, 1303)
expected8 = (109150, 109350, 111150, 109450)
expected9 = (0, 200, 2000, 300)


@pytest.mark.parametrize(
'test_tuple,expected_value', [
(tuple1, expected1), (tuple2, expected2), (tuple3, expected3),
(tuple4, expected4), (tuple5, expected5), (tuple6, expected6),
(tuple7, expected7), (tuple8, expected8), (tuple9, expected9)])
def test_FairShareTax(test_tuple, expected_value, skip_jit):
'''
Tests FairShareTax function
'''
test_value = calcfunctions.FairShareTax(*test_tuple)
assert np.allclose(test_value, expected_value)

4 changes: 3 additions & 1 deletion taxcalc/tests/test_cpscsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ def test_agg(tests_path, cps_fullsample):
raise ValueError(msg)
# create aggregate diagnostic table using unweighted sub-sample of records
rn_seed = 180 # to ensure sub-sample is always the same
subfrac = 0.03 # sub-sample fraction
subfrac = 0.07# 0.03 # sub-sample fraction
subsample = cps_fullsample.sample(frac=subfrac, random_state=rn_seed)
recs_subsample = Records.cps_constructor(data=subsample)
calc_subsample = Calculator(policy=baseline_policy, records=recs_subsample)
calc_subsample.advance_to_year(START_YEAR)
adt_subsample = calc_subsample.diagnostic_table(nyrs)
# compare combined tax liability from full and sub samples for each year
taxes_subsample = adt_subsample.loc["Combined Liability ($b)"]
print('taxes_submsampe = ', taxes_subsample)
print('TAXES full sample = ', taxes_fullsample)
msg = ''
for cyr in range(calc_start_year, calc_start_year + nyrs):
if cyr == calc_start_year:
Expand Down
38 changes: 17 additions & 21 deletions taxcalc/tests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
GrowFactors,
is_paramtools_format,
)
from taxcalc.growdiff import GrowDiff


# Test specification and use of simple Parameters-derived class that has
Expand Down Expand Up @@ -232,27 +233,22 @@ def test_json_file_contents(tests_path, fname):
param.get('indexable', False),
param['value_type'])
failures += fail + '\n'
# check that indexed parameters have all known years in value_yrs list
# (form_parameters are those whose value is available only on IRS form)
form_parameters = []
if param.get('indexed', False):
defined_years = set(
vo["year"] for vo in param["value"]
)
error = False
if pname in long_params:
exp_years = long_known_years
else:
exp_years = known_years
if pname in form_parameters:
if defined_years != exp_years:
error = True
else:
if defined_years != exp_years:
error = True
if error:
msg = 'param:<{}>; len(value_yrs)={}; known_years={}'
fail = msg.format(pname, len(defined_years), exp_years)
if fname == "consumption.json":
o = Consumption()
elif fname == "policy_current_law.json":
o = Policy()
elif fname == "growdiff.json":
o = GrowDiff()
param_list = []
for k, v in o.__dict__.items():
if k[0].isupper(): # find parameters by case of first letter
param_list.append(k)
for param in param_list:
for y in known_years:
o.set_year(y)
if np.isnan(o.__getattribute__(param)).any():
msg = 'param:<{}>; not found in year={}'
fail = msg.format(param, y)
failures += fail + '\n'
if failures:
raise ValueError(failures)
Expand Down
Loading

0 comments on commit c2b201f

Please sign in to comment.