ospc-org / ospc.org

Source code for PolicyBrain, ospc.org, and related assets.
MIT License
24 stars 32 forks source link

Decile distribution table entries not correct #794

Closed martinholmer closed 6 years ago

martinholmer commented 6 years ago

When I go to http://www.ospc.org/taxbrain/29588/ and click on the "Distribution Table" button and then on the "Income Deciles" button, I get these (obviously incorrect) results:

screen shot 2018-01-02 at 9 40 47 pm

The most obvious problem is in the right-most three columns where the income tax liabilities and the payroll tax liabilities don't add up to the combined income and payroll tax liabilities.

Is this a problem with the results generated by Tax-Calculator? Or is the display of the Tax-Calculator results incorrect in TaxBrain? Either way there is a bug somewhere.

These results are from a TaxBrain run specified by the user who raised Tax-Calculator issue 1806.

hdoupe commented 6 years ago

@martinholmer do you think #794 is related to #214?

martinholmer commented 6 years ago

@hdoupe asked:

do you think #794 is related to #214?

I don't think so. Issue #214 was about difference tables with bins, not about distribution tables with deciles.

The distribution tables generated by Tax-Calculator do not have the problem reported in #794. Consider the following:

iMac2:OSPC mrh$ conda install  -c ospc taxcalc
Solving environment: done
## Package Plan ##
  environment location: /Users/mrh/anaconda
  added / updated specs: 
    - taxcalc
The following NEW packages will be INSTALLED:
    taxcalc: 0.14.3-py27_0 ospc
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

iMac2:OSPC mrh$ cat disttable.py
from taxcalc import *
recs = Records.cps_constructor()
pol = Policy()
calc1 = Calculator(policy=pol, records=recs)
reform = {2017: {'_II_em': [0.0]}}
pol.implement_reform(reform)
assert pol.reform_errors == ''
calc2 = Calculator(policy=pol, records=recs)
calc1.advance_to_year(2017)
calc2.advance_to_year(2017)
calc1.calc_all()
calc2.calc_all()
dist1, dist2 = calc1.distribution_tables(calc2)
itax1 = dist1['iitax'] * 1e-9
itax2 = dist2['iitax'] * 1e-9
ptax1 = dist1['payrolltax'] * 1e-9
ptax2 = dist2['payrolltax'] * 1e-9
comb1 = dist1['combined'] * 1e-9
comb2 = dist2['combined'] * 1e-9
assert np.allclose(itax1 + ptax1, comb1)
assert np.allclose(itax2 + ptax2, comb2)

iMac2:OSPC mrh$ python disttable.py
You loaded data for 2014.
Tax-Calculator startup automatically extrapolated your data to 2014.
You loaded data for 2014.
Tax-Calculator startup automatically extrapolated your data to 2014.

iMac2:OSPC mrh$

The assert statements did not fail because itax+ptax always equals combined, but that is not what's shown in TaxBrain results cited in #794.

hdoupe commented 6 years ago

Thanks @martinholmer. I'll be back in the office next week and will have more time to dive into this.

siervicul commented 6 years ago

The 4th column from the right (AMT) has a problem too, as it shows AMT as being higher than taxable income. The payroll tax liability column is also far too high--total payroll tax liabilities should be close to the amount of income tax liabilities, as they're each roughly the same percentage of federal revenues.

I've also noticed that changing payroll taxes produces illogical results in the distribution table. Setting the Social Security tax rate to 6% instead of the default of 12.4% results in higher payroll tax liabilities, and 1% results in higher payroll tax liabilities than 6%! The "Total Liabilities by Calendar Year (Change)" table at the top of the results page correctly shows a large reduction in payroll tax liability, but the distribution table shows a slightly higher number than with default settings.

MattHJensen commented 6 years ago

I can replicate these issues. See a 1% OASDI tax rate here: http://www.ospc.org/taxbrain/30382/

My initial thought is that the columns in the tables are mislabeled.

hdoupe commented 6 years ago

My initial thought is that the columns in the tables are mislabeled.

I agree that the table columns are probably mislabeled. I'll dig into this today.

@martinholmer @siervicul @MattHJensen Thanks for the bug report.

hdoupe commented 6 years ago

The AMT column seems way off. I looked at the output straight from Tax-Calculator before it is processed by PolicyBrain with the following script:

import taxcalc
import numpy as np

kw = {
    'start_year': 2017,
    'use_full_sample': True,
    'user_mods': {
        u'policy': {
            2017: {
                u'_FICA_ss_trt': [0.01],
            }
        },
        u'growdiff_response': {},
        u'behavior': {},
        u'consumption': {},
        u'growdiff_baseline': {}
    },
    'year_n': 0,
    'use_puf_not_cps': True,
    'return_dict': False
}

results = taxcalc.tbi.run_nth_year_tax_calc_model(**kw)

assert np.allclose(
    (results['dist1_xdec']['iitax_0'] +
     results['dist1_xdec']['payrolltax_0']).values,
     results['dist1_xdec']['combined_0'].values,
     atol=0.0,
     rtol=0.01
)

assert np.allclose(
    (results['dist2_xdec']['iitax_0'] +
     results['dist2_xdec']['payrolltax_0']).values,
     results['dist2_xdec']['combined_0'].values,
     atol=0.0,
     rtol=0.01
)

_var = 'c09600_0'
print('variable', _var)
print('current law')
print(results['dist1_xdec'][_var])
print('reform')
print(results['dist2_xdec'][_var])

with output:

(aei_dropq) HDoupe-MacBook-Pro:taxbrain_server henrydoupe$ python one_year_test.py 
puf-read-time= 3.3
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
seed=890285609
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
elapsed time for this run: 85.7
('variable', 'c09600_0')
current law
0                 0
1         6,266,957
2        36,448,883
3        35,523,251
4        73,093,599
5        63,023,696
6        43,013,813
7       119,831,126
8       479,517,621
9    45,100,752,729
10   45,957,471,673
11    1,710,129,427
12   22,272,595,389
13   21,118,027,912
Name: c09600_0, dtype: float64
reform
0                 0
1         6,266,957
2        36,380,240
3        35,281,932
4        73,089,639
5        63,069,867
6        43,013,813
7       122,003,377
8       482,408,948
9    45,122,617,590
10   45,984,132,363
11    1,717,649,982
12   22,301,119,548
13   21,103,848,060
Name: c09600_0, dtype: float64
(aei_dropq) HDoupe-MacBook-Pro:taxbrain_server henrydoupe$ 

The corresponding TaxBrain results for AMT are: current law: screen shot 2018-01-12 at 1 37 20 pm

reform: screen shot 2018-01-12 at 1 37 48 pm

Link to run: http://www.ospc.org/taxbrain/30382/

I'm stumped right now. I'm having trouble figuring out which variables PolicyBrain is showing.

siervicul commented 6 years ago

The first five columns ("Returns" through "Itemizers") all seem off too. There must be more than 5.8 million returns and fewer than 96.3 billion itemizers, for example.

hdoupe commented 6 years ago

The table labels are definitely out of order. I wrote a script that runs one year of the model and presents the results when a dataframe is returned and when a dictionary is returned. This is toggled with the return_dict argument in tbi.run_nth_year_tax_calc_model. The labels in the dataframe are given by Tax-Calculator. So I assume that it is correctly labeled. I then compare the results from that with the results in dictionary form. The results in the dictionary form are given the column names the same way that TaxBrain gives column names: assume that the result list is in the same order as the distribution column name list.

import taxcalc
import numpy as np
import pandas as pd

kw = {
    'start_year': 2017,
    'use_full_sample': True,
    'user_mods': {
        u'policy': {
            2017: {
                u'_FICA_ss_trt': [0.01],
            }
        },
        u'growdiff_response': {},
        u'behavior': {},
        u'consumption': {},
        u'growdiff_baseline': {}
    },
    'year_n': 0,
    'use_puf_not_cps': True,
    'return_dict': False
}

results_df = taxcalc.tbi.run_nth_year_tax_calc_model(**kw)

assert np.allclose(
    (results_df['dist1_xdec']['iitax_0'] +
     results_df['dist1_xdec']['payrolltax_0']).values,
     results_df['dist1_xdec']['combined_0'].values,
     atol=0.0,
     rtol=0.01
)

assert np.allclose(
    (results_df['dist2_xdec']['iitax_0'] +
     results_df['dist2_xdec']['payrolltax_0']).values,
     results_df['dist2_xdec']['combined_0'].values,
     atol=0.0,
     rtol=0.01
)

# this equivalent to how TaxBrain aligns the results with the column names
kw['return_dict'] = True
results_dict = taxcalc.tbi.run_nth_year_tax_calc_model(**kw)
_var = '0-10_0'
print('variable', _var)

labels = taxcalc.DIST_TABLE_LABELS
dict_0_10 = {k: [v] for k, v in zip(labels, results_dict['dist1_xdec']["0-10_0"])}
dict_df_0_10 = pd.DataFrame(dict_0_10)

print('current law dist table by deciles for year 0 and decile 0-10')
print('\ndataframe version\n')
print(results_df['dist1_xdec'].iloc[0])
print('\ndict version\n')
print(dict_df_0_10.T)

and output:

(py27) HDoupe-MacBook-Pro:taxbrain_server henrydoupe$ python one_year_test.py 
puf-read-time= 2.7
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
seed=890285609
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
elapsed time for this run: 75.2
puf-read-time= 2.4
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
seed=890285609
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ValueError: "Buffer dtype mismatch, expected 'Python object' but got 'long'" in 'pandas._libs.lib.is_bool_array' ignored
elapsed time for this run: 57.6
('variable', '0-10_0')
current law dist table by deciles for year 0 and decile 0-10

dataframe version

num_returns_AMT_0                          0
num_returns_ItemDed_0                  7,061
s006_0                            17,003,872
num_returns_StandardDed_0         11,674,701
refund_0                       2,812,020,826
taxbc_0                          106,964,208
c04600_0                      71,567,842,017
c00100_0                    -124,029,518,735 <-----------AGI
iitax_0                       -2,604,771,486
aftertax_income_0           -123,341,543,274
c07100_0                           7,179,272
expanded_income_0           -119,457,202,047
standard_0                   104,429,418,369
payrolltax_0                   6,489,112,713
c04470_0                         414,629,782
c05800_0                         106,964,208
combined_0                     3,884,341,227
c04800_0                         992,064,341
c62100_0                    -131,398,553,811
othertaxes_0                     107,464,404
c09600_0                                   0
Name: 0, dtype: float64

dict version

                                                                   0
AGI                                                          7061.47 <--------------WRONG AGI (should be num_returns_ItemDed_0)
AMT                                                 -119457202047.22
AMT Filers                                                7179272.16
AMTI                                                -123341543274.27
After-Tax Expanded Income                                       0.00
Combined Payroll and Individual Income Tax Liab...  -131398553810.78
Expanded Income                                         107464403.61
Individual Income Tax Liabilities                      3884341227.04
Itemized Deduction                                      106964208.12
Itemizers                                              2812020825.94
Non-refundable Credits                                 6489112713.42
Other Taxes                                             414629781.59
Payroll Tax Liablities                                  992064340.84
Personal Exemption                                    71567842017.48
Refundable Credits                                      106964208.12
Regular Tax                                           -2604771486.37
Returns                                                         0.00
Standard Deduction                                       11674701.00
Standard Deduction Filers                                17003871.51
Tax before Credits                                   104429418369.14
Taxable Income                                      -124029518734.75 <------------- CORRECT AGI
(py27) HDoupe-MacBook-Pro:taxbrain_server henrydoupe$ 

You can see that AGI is clearly wrong. AGI is -124,029,518,735 in the dataframe and 7,061 in the dictionary.

It seems like either the order of the results has changed or the order has always been wrong. My hunch is that some of the results got mixed up after the changes to the TaxBrain/Tax-Calculator interface. @martinholmer do you have any insight into whether this makes sense?

martinholmer commented 6 years ago

@hdoupe, Thanks for your extensive script in PolicyBrain issue #794.

I must confess that I've never understood the reason T.J. put the results_dict argument into the tbi.run_nth_year_tax_calc_model function. Can you explain why TaxBrain needs the results both as a dictionary of DataFrames and as a dictionary of dictionaries? Which does TaxBrain use? Does it ever use both?

Also, are results variables mis-assigned in other tables (say, the distribution table with expanded-income BINS or the aggregate tables)?

hdoupe commented 6 years ago

@martinholmer No problem.

I must confess that I've never understood the reason T.J. put the results_dict argument into the tbi.run_nth_year_tax_calc_model function. Can you explain why TaxBrain needs the results both as a dictionary of DataFrames and as a dictionary of dictionaries? Which does TaxBrain use? Does it ever use both?

I don't understand that either. PolicyBrain only uses the dictionary results. However, the DataFrames haven proven to be useful in this situation since I've been able to use them as the "truth" that I can check the PolicyBrain dictionary against.

Also, are results variables mis-assigned in other tables (say, the distribution table with expanded-income BINS or the aggregate tables)?

Good question, I'll check.

hdoupe commented 6 years ago

It looks like the distribution tables are the only problem. The difference tables and aggregate tables look good to me.

Here's the updated script [Edited to show corresponding dataframe column names]:

import taxcalc
import numpy as np
import pandas as pd

kw = {
    'start_year': 2017,
    'use_full_sample': True,
    'user_mods': {
        u'policy': {
            2017: {
                u'_FICA_ss_trt': [0.01],
            }
        },
        u'growdiff_response': {},
        u'behavior': {},
        u'consumption': {},
        u'growdiff_baseline': {}
    },
    'year_n': 0,
    'use_puf_not_cps': True,
    'return_dict': False
}

results_df = taxcalc.tbi.run_nth_year_tax_calc_model(**kw)

assert np.allclose(
    (results_df['dist1_xdec']['iitax_0'] +
     results_df['dist1_xdec']['payrolltax_0']).values,
     results_df['dist1_xdec']['combined_0'].values,
     atol=0.0,
     rtol=0.01
)

assert np.allclose(
    (results_df['dist2_xdec']['iitax_0'] +
     results_df['dist2_xdec']['payrolltax_0']).values,
     results_df['dist2_xdec']['combined_0'].values,
     atol=0.0,
     rtol=0.01
)

kw['return_dict'] = True
results_dict = taxcalc.tbi.run_nth_year_tax_calc_model(**kw)

dist_labels = [str((lab, col)) for lab, col in zip(taxcalc.DIST_TABLE_LABELS, taxcalc.DIST_TABLE_COLUMNS)]
diff_labels = [str((lab, col)) for lab, col in zip(taxcalc.DIFF_TABLE_LABELS, taxcalc.DIFF_TABLE_COLUMNS)]

for table_id, _var, labels in [('dist1_xdec', '0-10_0', dist_labels),
                               ('dist1_xbin', '<$10K_0', dist_labels),
                               ('diff_itax_xdec', '0-10_0', diff_labels),
                               ('diff_ptax_xbin', '<$10K_0', diff_labels)]:
    dict_0_10 = {k: [v] for k, v in zip(labels, results_dict[table_id][_var])}
    dict_df_0_10 = pd.DataFrame(dict_0_10)

    print('\n\ncurrent law dist table by {} for year 0 and var {}'.format(table_id, _var))
    print('\ndataframe version\n')
    print(results_df[table_id].iloc[0])
    print('\ndict version\n')
    print(dict_df_0_10.T)

print('\n\ncurrent law aggregate results')
print('\ndataframe version\n')
print(results_df['aggr_d'])
print('\ndict version\n')
print(results_dict['aggr_d'])

and output:

HDoupe-MacBook-Pro:taxbrain_server henrydoupe$ python one_year_test.py 
puf-read-time= 3.1
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
seed=3445877839
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
elapsed time for this run: 78.3
puf-read-time= 2.8
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
You loaded data for 2009.
Tax-Calculator startup automatically extrapolated your data to 2013.
seed=3445877839
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
Exception ignored in: 'pandas._libs.lib.is_bool_array'
ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'
elapsed time for this run: 63.4

current law dist table by dist1_xdec for year 0 and var 0-10_0

dataframe version

s006_0                            17,003,872
num_returns_AMT_0                          0
num_returns_StandardDed_0         11,674,701
num_returns_ItemDed_0                  7,061
c05800_0                         106,964,208
standard_0                   104,429,418,369
othertaxes_0                     107,464,404
c09600_0                                   0
c62100_0                    -131,398,553,811
aftertax_income_0           -123,341,543,274
c04470_0                         414,629,782
c04800_0                         992,064,341
iitax_0                       -2,604,771,486
c04600_0                      71,567,842,017
c07100_0                           7,179,272
taxbc_0                          106,964,208
c00100_0                    -124,029,518,735
payrolltax_0                   6,489,112,713
combined_0                     3,884,341,227
refund_0                       2,812,020,826
expanded_income_0           -119,457,202,047
Name: 0, dtype: float64

dict version

                                                                   0
('AGI', 'c00100')                                               0.00
('AMT Filers', 'num_returns_AMT')                       414629781.59
('AMT', 'c09600')                                       992064340.84
('AMTI', 'c62100')                                  -123341543274.27
('After-Tax Expanded Income', 'aftertax_income')    -119457202047.22
('Combined Payroll and Individual Income Tax Li...     3884341227.04
('Expanded Income', 'expanded_income')                 2812020825.94
('Individual Income Tax Liabilities', 'iitax')      -124029518734.75
('Itemized Deduction', 'c04470')                     104429418369.14
('Itemizers', 'num_returns_ItemDed')                    106964208.12
('Non-refundable Credits', 'c07100')                  71567842017.48
('Other Taxes', 'othertaxes')                             7179272.16
('Payroll Tax Liablities', 'payrolltax')               6489112713.42
('Personal Exemption', 'c04600')                        107464403.61
('Refundable Credits', 'refund')                        106964208.12
('Regular Tax', 'taxbc')                            -131398553810.78
('Returns', 's006')                                      17003871.51
('Standard Deduction Filers', 'num_returns_Stan...       11674701.00
('Standard Deduction', 'standard')                           7061.47
('Tax before Credits', 'c05800')                      -2604771486.37
('Taxable Income', 'c04800')                                    0.00

current law dist table by dist1_xbin for year 0 and var <$10K_0

dataframe version

s006_0                           23,164,577
num_returns_AMT_0                     6,064
num_returns_StandardDed_0        21,087,255
num_returns_ItemDed_0                23,258
c05800_0                        249,903,309
standard_0                  146,130,334,880
othertaxes_0                     59,340,591
c09600_0                          2,303,920
c62100_0                     89,332,257,085
aftertax_income_0           111,365,823,037
c04470_0                        152,210,710
c04800_0                      3,291,787,490
iitax_0                      -8,250,794,966
c04600_0                     92,871,732,114
c07100_0                          1,759,876
taxbc_0                         247,599,389
c00100_0                     89,611,133,196
payrolltax_0                 12,364,787,785
combined_0                    4,113,992,819
refund_0                      8,558,278,990
expanded_income_0           115,479,815,856
Name: 1, dtype: float64

dict version

                                                                  0
('AGI', 'c00100')                                           6063.67
('AMT Filers', 'num_returns_AMT')                      152210710.01
('AMT', 'c09600')                                     3291787490.15
('AMTI', 'c62100')                                  111365823036.98
('After-Tax Expanded Income', 'aftertax_income')    115479815855.85
('Combined Payroll and Individual Income Tax Li...    4113992818.87
('Expanded Income', 'expanded_income')                8558278990.25
('Individual Income Tax Liabilities', 'iitax')       89611133196.08
('Itemized Deduction', 'c04470')                    146130334880.36
('Itemizers', 'num_returns_ItemDed')                   249903309.04
('Non-refundable Credits', 'c07100')                 92871732114.00
('Other Taxes', 'othertaxes')                            1759875.95
('Payroll Tax Liablities', 'payrolltax')             12364787785.20
('Personal Exemption', 'c04600')                        59340590.84
('Refundable Credits', 'refund')                       247599388.73
('Regular Tax', 'taxbc')                             89332257085.09
('Returns', 's006')                                     23164576.69
('Standard Deduction Filers', 'num_returns_Stan...      21087255.01
('Standard Deduction', 'standard')                         23258.19
('Tax before Credits', 'c05800')                     -8250794966.33
('Taxable Income', 'c04800')                             2303920.30

current law dist table by diff_itax_xdec for year 0 and var 0-10_0

dataframe version

count_0             17,004,755
tax_cut_0              812,834
perc_cut_0                   5
tax_inc_0               92,630
perc_inc_0                   1
mean_0                      -0
tot_change_0        -6,742,615
share_of_change_0           -0
perc_aftertax_0              0
pc_aftertaxinc_0            -2
Name: 0, dtype: float64

dict version

                                                              0
('% Change in After-Tax Income', 'pc_aftertaxinc')        -2.36
('All Tax Units', 'count')                          17004754.74
('Average Tax Change', 'mean')                            -0.40
('Change as % of After-Tax Income', 'perc_after...         0.01
('Percent with Tax Cut', 'perc_cut')                       4.78
('Percent with Tax Increase', 'perc_inc')                  0.54
('Share of Overall Change', 'share_of_change')            -0.20
('Tax Units with Tax Cut', 'tax_cut')                 812834.21
('Tax Units with Tax Increase', 'tax_inc')             92629.51
('Total Tax Difference', 'tot_change')              -6742615.17

current law dist table by diff_ptax_xbin for year 0 and var <$10K_0

dataframe version

count_0                 23,164,577
tax_cut_0               17,156,238
perc_cut_0                      74
tax_inc_0                        0
perc_inc_0                       0
mean_0                        -396
tot_change_0        -9,178,076,140
share_of_change_0                1
perc_aftertax_0                 -8
pc_aftertaxinc_0                 5
Name: 1, dtype: float64

dict version

                                                                 0
('% Change in After-Tax Income', 'pc_aftertaxinc')            4.83
('All Tax Units', 'count')                             23164576.69
('Average Tax Change', 'mean')                             -396.21
('Change as % of After-Tax Income', 'perc_after...           -8.24
('Percent with Tax Cut', 'perc_cut')                         74.06
('Percent with Tax Increase', 'perc_inc')                     0.00
('Share of Overall Change', 'share_of_change')                1.18
('Tax Units with Tax Cut', 'tax_cut')                  17156238.10
('Tax Units with Tax Increase', 'tax_inc')                    0.00
('Total Tax Difference', 'tot_change')              -9178076139.53

current law aggregate results

dataframe version

                          0_0
ind_tax         3,411,140,610
payroll_tax  -777,399,077,280
combined_tax -773,987,936,670

dict version

{'ind_tax_0': '3411140610.39', 'payroll_tax_0': '-777399077280.15', 'combined_tax_0': '-773987936669.75'}
HDoupe-MacBook-Pro:taxbrain_server henrydoupe$ 
martinholmer commented 6 years ago

This Tax-Calculator bug has been fixed in Tax-Calculator pull request 1834. Thanks @hdoupe for the extensive diagnosis of the problems caused by the bug.