Skip to content

Commit

Permalink
Merge master into add-hc-vs-bs-test branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Jul 27, 2016
2 parents 7517aec + 0474d8f commit 1f5ea9d
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 39 deletions.
63 changes: 63 additions & 0 deletions taxcalc/calculate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
Tax-Calculator federal tax Calculator class.
"""
# CODING-STYLE CHECKS:
# pep8 --ignore=E402 calculate.py


import math
import copy
import numpy as np
Expand All @@ -17,6 +21,65 @@


class Calculator(object):
"""
Constructor for the Calculator class.
Parameters
----------
policy: Policy class object
this argument must be specified
IMPORTANT NOTE: never pass the same Policy object to more than one
Calculator. In other words, when specifying more
than one Calculator object, do this:
pol1 = Policy()
rec1 = Records()
calc1 = Calculator(policy=pol1, records=rec1)
pol2 = Policy()
rec2 = Records()
calc2 = Calculator(policy=pol2, records=rec2)
records: Records class object
this argument must be specified
IMPORTANT NOTE: never pass the same Records object to more than one
Calculator. In other words, when specifying more
than one Calculator object, do this:
pol1 = Policy()
rec1 = Records()
calc1 = Calculator(policy=pol1, records=rec1)
pol2 = Policy()
rec2 = Records()
calc2 = Calculator(policy=pol2, records=rec2)
verbose: boolean
specifies whether or not to write to stdout data-loaded and
data-extrapolated progress reports; default value is true.
sync_years: boolean
specifies whether or not to syncronize policy year and records year;
default value is true.
behavior: Behavior class object
specifies behaviorial responses used by Calculator; default is None,
which implies no behavioral responses.
growth: Growth class object
specifies economic growth assumptions used by Calculator; default is
None, which implies use of standard economic growth assumptions.
consumption: Consumption class object
specifies consumption response assumptions used to calculate
"effective" marginal tax rates; default is None, which implies
no consumption responses.
Raises
------
ValueError:
if parameters are not the appropriate type.
Returns
-------
class instance: Calculator
"""

def __init__(self, policy=None, records=None, verbose=True,
sync_years=True, behavior=None, growth=None,
Expand Down
26 changes: 13 additions & 13 deletions taxcalc/comparison/reform_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Tax-Calculator,0.8,0.8,0.9,1.0
SOCIAL SECURITY TAXABILITY
""
Exclusion of untaxed social security and railroad retirement
Tax-Calculator,39.5,41.3,43.9,46.4
Tax-Calculator,39.3,41.0,43.9,46.4
Tax Expenditure,39,42,44,47
Budget Options,35,37,38,40
""
Expand Down Expand Up @@ -50,7 +50,7 @@ Tax-Calculator,0.1,0.1,0.1,0.1
EXEMPTION
""
Increase personal and dependent exemption amount by 1000
Tax-Calculator,-32.9,-32.3,-33.3,-34.5
Tax-Calculator,-32.8,-32.2,-33.3,-34.5
""
Increase personal exemption phaseout starting AGI by 10,000
Tax-Calculator,-0.1,-0.1,-0.1,-0.1
Expand All @@ -64,36 +64,36 @@ Increase standard deduction by 100
Tax-Calculator,-1.0,-1.1,-1.1,-1.1
""
Increase additional standard deduction for aged and blind by 100
Tax-Calculator,-0.3,-0.3,-0.3,-0.3
Tax-Calculator,-0.2,-0.3,-0.3,-0.3
""
ITEMIZED DEDUCTION
""
Real Estate
Tax-Calculator,35.6,37.7,39.8,41.8
Tax-Calculator,35.7,37.8,39.8,41.8
Tax Expenditure,34,36,39,41
""
Home Mortgage
Tax-Calculator,80.3,87.6,94.5,101.3
Tax-Calculator,80.4,87.7,94.5,101.3
Tax Expenditure,75,82,88,93
""
Both real estate and state and local
Tax-Calculator,99.0,105.3,111.4,117.5
Tax-Calculator,99.3,105.6,111.4,117.5
Tax Expenditure,75,82,88,93
""
State & Local
Tax-Calculator,64.2,67.8,71.3,75.0
Tax-Calculator,64.3,67.9,71.3,75.0
Tax Expenditure,59,63,67,71
""
Medical
Tax-Calculator,8.4,9.2,9.9,10.7
Tax-Calculator,9.4,10.3,9.9,10.7
Tax Expenditure,11,12,13,14
""
Casualty
Tax-Calculator,0.4,0.5,0.5,0.5
Tax Expenditure,0,0,0,0
""
Charitable
Tax-Calculator,43.1,45.6,48.2,50.9
Tax-Calculator,43.2,45.8,48.2,50.9
Tax Expenditure,46,47,48,50
""
Decrease AGI floor for miscellaneous expenses by 1 pts
Expand All @@ -109,7 +109,7 @@ Increase Itemized Deduction phaseout rate by 1 pts
Tax-Calculator,3.6,3.8,4.0,4.1
""
limit the tax value of ID to 6% of AGI
Tax-Calculator,19.5,20.8,22.2,23.7
Tax-Calculator,19.6,21.0,22.2,23.7
Budget Options,11,9,8,7
""
CAPITAL GAIN
Expand All @@ -118,7 +118,7 @@ Increase long term cap gain and dividends tax rates by 2 percentage, no behavior
Tax-Calculator,13.2,13.5,13.7,14.0
""
Increase long term cap gain and dividends tax rates by 2 percentage, elasticity assumed to be 0.78
Tax-Calculator,10.4,10.6,10.8,11.0
Tax-Calculator,10.3,10.6,10.8,11.0
""
Increase long term cap gain and dividends tax rates by 2 percentage, elasticity assumed to be 1.2
Tax-Calculator,8.8,9.0,9.2,9.4
Expand All @@ -127,7 +127,7 @@ Budget Options,5,5,5,6
REGULAR TAXES
""
Increase each bracket rate by 1%
Tax-Calculator,56.3,58.8,61.5,64.0
Tax-Calculator,56.2,58.7,61.5,64.0
Budget Options,56,60,65,69
""
Increase top 4 rates by 1%
Expand All @@ -146,7 +146,7 @@ Tax-Calculator,-1.0,-0.8,-0.9,-0.9
Alternative Minimum Tax
""
Increase exemption phaseout starting AMTI by 10,000
Tax-Calculator,-2.3,-2.3,-2.5,-2.6
Tax-Calculator,-2.3,-2.4,-2.5,-2.6
""
Alternative Minimum Tax
""
Expand Down
15 changes: 15 additions & 0 deletions taxcalc/current_law_policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,21 @@
"validations": {"min": "default"}
},

"_ID_Medical_frt_add4aged": {
"long_name": "Addon to _ID_Medical_frt for elderly filing units; addon as a decimal fraction of AGI",
"description": "Elderly taxpayers have this fraction added to the value of _ID_Medical_frt.",
"irs_ref": "Form 1040 Schedule A, line 3, in-line. ",
"notes": "This addon cannot be decreased to lower than -0.025 due to limited data on elderly non-itemizers.",
"start_year": 2013,
"col_var": "",
"row_var": "FLPDYR",
"row_label": ["2013", "2014", "2015", "2016", "2017"],
"cpi_inflated": false,
"col_label": "",
"value": [-0.025, -0.025, -0.025, -0.025, 0.0],
"validations": {"min": -0.025, "max": 0.0}
},

"_ID_Medical_HC": {
"long_name": "Medical expense deduction haircut",
"description": "This decimal fraction can be applied to limit the amount of medical expense deduction allowed.",
Expand Down
13 changes: 10 additions & 3 deletions taxcalc/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ def AGI(ymod1, c02500, c02700, c02900, XTOT, MARS, _sep, DSI,
@iterate_jit(nopython=True)
def ItemDed(_posagi, e17500, e18400, e18500,
e20500, e20400, e19200, e19800, e20100,
MARS, c00100, c04470, c17000, c18300, c20800, c21040, c21060,
ID_ps, ID_Medical_frt, ID_Medical_HC,
MARS, age_head, age_spouse,
c00100, c04470, c17000, c18300, c20800, c21040, c21060,
ID_ps, ID_Medical_frt, ID_Medical_frt_add4aged, ID_Medical_HC,
ID_Casualty_frt_in_pufcsv_year,
ID_Casualty_frt, ID_Casualty_HC, ID_Miscellaneous_frt,
ID_Miscellaneous_HC, ID_Charity_crt_all, ID_Charity_crt_noncash,
Expand All @@ -234,6 +235,9 @@ def ItemDed(_posagi, e17500, e18400, e18500,
ID_Medical_frt : Deduction for medical expenses;
floor as a decimal fraction of AGI
ID_Medical_frt_add4aged : Addon for medical expenses deduction for
elderly; addon as a decimal fraction of AGI
ID_Casualty_frt : Deduction for casualty loss;
floor as a decimal fraction of AGI
Expand Down Expand Up @@ -271,7 +275,10 @@ def ItemDed(_posagi, e17500, e18400, e18500,
c04470 : Itemized deduction amount (and other intermediate variables)
"""
# Medical
c17750 = ID_Medical_frt * _posagi
medical_frt = ID_Medical_frt
if age_head >= 65 or (MARS == 2 and age_spouse >= 65):
medical_frt += ID_Medical_frt_add4aged
c17750 = medical_frt * _posagi
c17000 = max(0., e17500 - c17750) * (1. - ID_Medical_HC)
# State and local taxes
c18300 = ((1. - ID_StateLocalTax_HC) * max(e18400, 0.) +
Expand Down
22 changes: 11 additions & 11 deletions taxcalc/tests/pufcsv_agg_expect.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
2013 2014 2015 2016 2017 2018 2019 2020 2021 2022
Returns (#m) 162.9 165.2 167.7 170.1 172.4 174.1 175.6 177.1 178.4 179.8
AGI ($b) 9,160.6 9,697.4 10,079.4 10,507.8 10,960.8 11,406.5 11,828.8 12,284.2 12,786.1 13,327.2
Itemizers (#m) 42.2 42.8 43.7 44.7 45.4 46.0 46.5 47.1 47.5 48.1
Itemized Deduction ($b) 1,103.2 1,148.3 1,211.6 1,282.4 1,351.9 1,426.2 1,501.2 1,580.5 1,662.0 1,749.6
Standard Deduction Filers (#m) 108.3 109.6 111.1 112.3 113.6 114.4 115.1 115.8 116.3 116.8
Standard Deduction ($b) 929.1 956.0 985.1 997.1 1,023.1 1,055.6 1,087.4 1,121.4 1,155.5 1,191.4
Itemizers (#m) 42.4 43.0 43.8 44.8 45.4 46.0 46.5 47.1 47.5 48.1
Itemized Deduction ($b) 1,111.1 1,156.5 1,219.9 1,290.4 1,351.9 1,426.2 1,501.2 1,580.5 1,662.0 1,749.6
Standard Deduction Filers (#m) 108.1 109.4 110.9 112.2 113.6 114.4 115.1 115.8 116.3 116.8
Standard Deduction ($b) 926.7 953.7 983.1 995.8 1,023.1 1,055.6 1,087.4 1,121.4 1,155.5 1,191.4
Personal Exemption ($b) 1,117.6 1,139.7 1,165.9 1,191.4 1,218.1 1,254.5 1,290.8 1,329.3 1,368.1 1,408.6
Taxable income ($b) 6,449.8 6,919.4 7,185.5 7,508.4 7,846.2 8,159.5 8,450.4 8,763.1 9,123.0 9,514.7
Regular Tax ($b) 1,396.4 1,523.6 1,574.4 1,646.3 1,721.7 1,787.3 1,846.3 1,912.1 1,990.4 2,076.3
AMT income ($b) 8,577.6 9,087.8 9,434.5 9,821.4 10,233.6 10,636.8 11,016.4 11,426.5 11,881.4 12,372.6
AMT amount ($b) 31.3 32.9 34.5 36.8 38.9 41.1 43.3 45.7 48.2 51.1
Taxable income ($b) 6,444.8 6,914.0 7,179.7 7,502.2 7,846.2 8,159.5 8,450.4 8,763.1 9,123.0 9,514.7
Regular Tax ($b) 1,395.5 1,522.6 1,573.4 1,645.2 1,721.7 1,787.3 1,846.3 1,912.1 1,990.4 2,076.3
AMT income ($b) 8,571.7 9,081.5 9,428.1 9,814.9 10,233.6 10,636.8 11,016.4 11,426.5 11,881.4 12,372.6
AMT amount ($b) 31.3 32.9 34.6 36.8 38.9 41.1 43.3 45.7 48.2 51.1
AMT number (#m) 4.2 4.4 4.6 4.9 5.1 5.3 5.4 5.6 5.7 5.9
Tax before credits ($b) 1,339.1 1,437.9 1,492.0 1,563.5 1,639.3 1,705.3 1,765.6 1,831.2 1,908.3 1,992.7
Tax before credits ($b) 1,338.2 1,436.9 1,491.0 1,562.4 1,639.3 1,705.3 1,765.6 1,831.2 1,908.3 1,992.7
refundable credits ($b) 111.5 112.5 113.9 113.6 114.5 116.0 117.6 119.3 120.9 122.5
nonrefundable credits ($b) 71.6 71.7 72.1 72.7 74.1 74.9 75.3 76.2 77.1 78.0
Misc. Surtax ($b) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Ind inc tax ($b) 1,227.0 1,331.9 1,385.7 1,459.6 1,536.3 1,602.5 1,663.3 1,729.3 1,807.4 1,893.0
Ind inc tax ($b) 1,226.1 1,331.0 1,384.7 1,458.5 1,536.3 1,602.5 1,663.3 1,729.3 1,807.4 1,893.0
Payroll tax ($b) 919.6 961.9 1,003.7 1,045.3 1,093.9 1,141.4 1,186.7 1,233.7 1,284.4 1,338.8
Combined liability ($b) 2,146.7 2,293.8 2,389.4 2,504.8 2,630.2 2,743.9 2,849.9 2,962.9 3,091.8 3,231.9
Combined liability ($b) 2,145.8 2,292.9 2,388.3 2,503.7 2,630.2 2,743.9 2,849.9 2,962.9 3,091.8 3,231.9
24 changes: 12 additions & 12 deletions taxcalc/tests/pufcsv_mtr_expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ IIT mtr histogram bin edges:
[-1.0, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 1.0]
FICA and IIT mtr histogram bin counts for e00200p:
219814 : 0 31950 0 0 0 0 0 183680 4184 0
219814 : 4596 91 1978 8884 45423 63084 48462 26218 20404 674
219814 : 4596 91 1978 8884 45494 63307 48646 25757 20400 661
FICA and IIT mtr histogram bin counts for e00900p:
219814 : 14116 29235 0 0 0 0 0 176463 0 0
219814 : 3328 524 795 164 15286 35231 69928 47788 36743 10027
219814 : 3328 524 795 164 15289 35313 69931 47719 36739 10012
FICA and IIT mtr histogram bin counts for e00300:
219814 : 219814 0 0 0 0 0 0 0 0 0
219814 : 0 0 0 0 60203 62712 43785 26597 25814 703
219814 : 0 0 0 0 60274 62935 43965 26140 25810 690
FICA and IIT mtr histogram bin counts for e00400:
219814 : 219814 0 0 0 0 0 0 0 0 0
219814 : 0 0 0 0 205670 7895 6110 102 29 8
219814 : 0 0 0 0 205699 7875 6101 102 29 8
FICA and IIT mtr histogram bin counts for e00600:
219814 : 219814 0 0 0 0 0 0 0 0 0
219814 : 0 0 0 0 60201 62729 43957 26415 25809 703
219814 : 0 0 0 0 60272 62952 44137 25958 25805 690
FICA and IIT mtr histogram bin counts for e00650:
219814 : 219814 0 0 0 0 0 0 0 0 0
219814 : 0 0 6 17827 106089 44407 50432 630 399 24
219814 : 0 0 6 17796 106419 44115 50439 628 387 24
FICA and IIT mtr histogram bin counts for e01400:
219814 : 219814 0 0 0 0 0 0 0 0 0
219814 : 0 0 0 0 60151 62824 47562 26866 21722 689
219814 : 0 0 0 0 60224 63045 47744 26407 21718 676
FICA and IIT mtr histogram bin counts for e01700:
219814 : 219814 0 0 0 0 0 0 0 0 0
219814 : 0 0 0 0 60147 62827 47545 26883 21723 689
219814 : 0 0 0 0 60220 63048 47726 26425 21719 676
FICA and IIT mtr histogram bin counts for e02000:
219814 : 219814 0 0 0 0 0 0 0 0 0
219814 : 0 0 0 0 60174 62777 44325 26322 25517 699
219814 : 0 0 0 0 60245 63000 44512 25858 25513 686
FICA and IIT mtr histogram bin counts for e02400:
219814 : 219814 0 0 0 0 0 0 0 0 0
219814 : 0 0 0 0 96269 41042 52054 29562 781 106
219814 : 0 0 0 0 96304 41039 52018 29569 778 106
FICA and IIT mtr histogram bin counts for p22250:
219814 : 219814 0 0 0 0 0 0 0 0 0
219814 : 0 0 0 15 82468 60583 42419 19267 14642 420
219814 : 0 0 0 15 82527 60776 42568 18880 14640 408
FICA and IIT mtr histogram bin counts for p23250:
219814 : 219814 0 0 0 0 0 0 0 0 0
219814 : 0 0 2 17063 124734 38750 34115 2163 2936 51
219814 : 0 0 2 17041 124994 38532 34138 2132 2928 47
10 changes: 10 additions & 0 deletions taxcalc/tests/test_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@ def test_read_json_reform_file_and_implement_reform_a(reform_file):
assert amt_em[2020 - syr, 0] == amt_em[2017 - syr, 0]
assert amt_em[2021 - syr, 0] > amt_em[2020 - syr, 0]
assert amt_em[2022 - syr, 0] > amt_em[2021 - syr, 0]
add4aged = policy._ID_Medical_frt_add4aged
assert add4aged[2015 - syr] == -0.025
assert add4aged[2016 - syr] == -0.025
assert add4aged[2017 - syr] == 0.0
assert add4aged[2022 - syr] == 0.0


def test_read_json_reform_file_and_implement_reform_b(reform_file):
Expand Down Expand Up @@ -620,6 +625,11 @@ def test_read_json_reform_file_and_implement_reform_b(reform_file):
assert amt_em[2020 - syr, 0] == amt_em[2017 - syr, 0]
assert amt_em[2021 - syr, 0] > amt_em[2020 - syr, 0]
assert amt_em[2022 - syr, 0] > amt_em[2021 - syr, 0]
add4aged = policy._ID_Medical_frt_add4aged
assert add4aged[2015 - syr] == -0.025
assert add4aged[2016 - syr] == -0.025
assert add4aged[2017 - syr] == 0.0
assert add4aged[2022 - syr] == 0.0


def test_pop_the_cap_reform():
Expand Down

0 comments on commit 1f5ea9d

Please sign in to comment.