Basic Recipe: Static Analysis of a Simple Reform
Contents
Basic Recipe: Static Analysis of a Simple Reform#
This is the recipe you should follow first. Mastering this recipe is a prerequisite for all the other recipes in this cookbook.
Imports#
import taxcalc as tc
import pandas as pd
from bokeh.io import show, output_notebook
Setup#
Use publicly-available CPS input file.
NOTE: if you have access to the restricted-use IRS-SOI PUF-based input file and you have that file (named ‘puf.csv’) located in the directory where this script is located, then you can substitute the following statement for the prior statement:
recs = tc.Records()
recs = tc.Records.cps_constructor()
Specify Calculator object for static analysis of current-law policy.
pol = tc.Policy()
calc1 = tc.Calculator(policy=pol, records=recs)
NOTE: calc1 now contains a PRIVATE COPY of pol and a PRIVATE COPY of recs, so we can continue to use pol and recs in this script without any concern about side effects from Calculator method calls on calc1.
CYR = 2020
Calculate aggregate current-law income tax liabilities for CYR.
calc1.advance_to_year(CYR)
calc1.calc_all()
itax_rev1 = calc1.weighted_total('iitax')
Read JSON reform file and use (the default) static analysis assumptions.
reform_filename = 'github://PSLmodels:[email protected]/docs/recipes/_static/reformA.json'
params = tc.Calculator.read_json_param_objects(reform_filename, None)
Specify Calculator object for static analysis of reform policy.
pol.implement_reform(params['policy'])
calc2 = tc.Calculator(policy=pol, records=recs)
Calculate#
Calculate reform income tax liabilities for CYR.
calc2.advance_to_year(CYR)
calc2.calc_all()
itax_rev2 = calc2.weighted_total('iitax')
Results#
Print total revenue estimates for 2018.
Estimates in billons of dollars rounded to nearest hundredth of a billion.
print('{}_CLP_itax_rev($B)= {:.3f}'.format(CYR, itax_rev1 * 1e-9))
print('{}_REF_itax_rev($B)= {:.3f}'.format(CYR, itax_rev2 * 1e-9))
2020_CLP_itax_rev($B)= 712.667
2020_REF_itax_rev($B)= 714.208
Generate several other standard results tables.
# Aggregate diagnostic tables for CYR.
clp_diagnostic_table = calc1.diagnostic_table(1)
ref_diagnostic_table = calc2.diagnostic_table(1)
# Income-tax distribution for CYR with CLP and REF results side-by-side.
dist_table1, dist_table2 = calc1.distribution_tables(calc2, 'weighted_deciles')
assert isinstance(dist_table1, pd.DataFrame)
assert isinstance(dist_table2, pd.DataFrame)
dist_extract = pd.DataFrame()
dist_extract['funits(#m)'] = dist_table1['count']
dist_extract['itax1($b)'] = dist_table1['iitax']
dist_extract['itax2($b)'] = dist_table2['iitax']
dist_extract['aftertax_inc1($b)'] = dist_table1['aftertax_income']
dist_extract['aftertax_inc2($b)'] = dist_table2['aftertax_income']
# Income-tax difference table by expanded-income decile for CYR.
diff_table = calc1.difference_table(calc2, 'weighted_deciles', 'iitax')
assert isinstance(diff_table, pd.DataFrame)
diff_extract = pd.DataFrame()
dif_colnames = ['count', 'tot_change', 'mean', 'pc_aftertaxinc']
ext_colnames = ['funits(#m)', 'agg_diff($b)', 'mean_diff($)', 'aftertaxinc_diff(%)']
for dname, ename in zip(dif_colnames, ext_colnames):
diff_extract[ename] = diff_table[dname]
Plotting#
Generate a decile graph and display it using Bokeh (will render in Jupyter, not in webpage).
Print tables#
CLP diagnostic table for CYR.
clp_diagnostic_table
2020 | |
---|---|
Returns (#m) | 204.480 |
AGI ($b) | 11338.160 |
Itemizers (#m) | 27.080 |
Itemized Deduction ($b) | 733.405 |
Standard Deduction Filers (#m) | 177.400 |
Standard Deduction ($b) | 3088.310 |
Personal Exemption ($b) | 0.000 |
Taxable Income ($b) | 8372.949 |
Regular Tax ($b) | 1457.697 |
AMT Income ($b) | 10791.932 |
AMT Liability ($b) | 0.436 |
AMT Filers (#m) | 0.080 |
Tax before Credits ($b) | 1458.133 |
Refundable Credits ($b) | 657.660 |
Nonrefundable Credits ($b) | 98.801 |
Reform Surtaxes ($b) | 0.000 |
Other Taxes ($b) | 10.995 |
Ind Income Tax ($b) | 712.667 |
Payroll Taxes ($b) | 1206.565 |
Combined Liability ($b) | 1919.232 |
With Income Tax <= 0 (#m) | 135.980 |
With Combined Tax <= 0 (#m) | 98.670 |
UBI Benefits ($b) | 0.000 |
Total Benefits, Consumption Value ($b) | 3617.949 |
Total Benefits Cost ($b) | 3617.949 |
REF diagnostic table for CYR.
ref_diagnostic_table
2020 | |
---|---|
Returns (#m) | 204.480 |
AGI ($b) | 11338.160 |
Itemizers (#m) | 27.010 |
Itemized Deduction ($b) | 730.891 |
Standard Deduction Filers (#m) | 177.470 |
Standard Deduction ($b) | 3089.620 |
Personal Exemption ($b) | 375.177 |
Taxable Income ($b) | 8126.319 |
Regular Tax ($b) | 1456.850 |
AMT Income ($b) | 10794.282 |
AMT Liability ($b) | 0.453 |
AMT Filers (#m) | 0.080 |
Tax before Credits ($b) | 1457.303 |
Refundable Credits ($b) | 661.001 |
Nonrefundable Credits ($b) | 93.088 |
Reform Surtaxes ($b) | 0.000 |
Other Taxes ($b) | 10.995 |
Ind Income Tax ($b) | 714.208 |
Payroll Taxes ($b) | 1206.565 |
Combined Liability ($b) | 1920.773 |
With Income Tax <= 0 (#m) | 138.300 |
With Combined Tax <= 0 (#m) | 99.410 |
UBI Benefits ($b) | 0.000 |
Total Benefits, Consumption Value ($b) | 3617.949 |
Total Benefits Cost ($b) | 3617.949 |
Extract of CYR distribution tables by baseline expanded-income decile.
dist_extract
funits(#m) | itax1($b) | itax2($b) | aftertax_inc1($b) | aftertax_inc2($b) | |
---|---|---|---|---|---|
0-10n | 0.103662 | -0.292423 | -0.292423 | -6.460430 | -6.460430 |
0-10z | 8.289516 | -17.339037 | -17.339037 | 17.339037 | 17.339037 |
0-10p | 12.054047 | -25.552758 | -25.552758 | 65.695513 | 65.695513 |
10-20 | 20.448097 | -52.575845 | -52.911009 | 305.338318 | 305.673482 |
20-30 | 20.449272 | -53.685640 | -54.709242 | 538.018756 | 539.042358 |
30-40 | 20.448454 | -47.247852 | -48.492951 | 713.831606 | 715.076705 |
40-50 | 20.448974 | -44.931112 | -46.627557 | 881.988898 | 883.685343 |
50-60 | 20.447937 | -40.474885 | -43.110606 | 1092.103461 | 1094.739182 |
60-70 | 20.448353 | -31.673458 | -35.335983 | 1370.753695 | 1374.416220 |
70-80 | 20.448556 | -0.391671 | -5.206184 | 1727.227658 | 1732.042171 |
80-90 | 20.448771 | 79.533191 | 71.492901 | 2270.039481 | 2278.079771 |
90-100 | 20.448526 | 947.298181 | 972.293122 | 4617.620976 | 4592.626035 |
ALL | 204.484164 | 712.666690 | 714.208273 | 13593.496970 | 13591.955387 |
90-95 | 10.223657 | 135.324211 | 129.791334 | 1512.250619 | 1517.783495 |
95-99 | 8.180007 | 311.466520 | 308.837934 | 1787.583592 | 1790.212177 |
Top 1% | 2.044862 | 500.507450 | 533.663854 | 1317.786766 | 1284.630363 |
Extract of CYR income-tax difference table by expanded-income decile.
diff_extract
funits(#m) | agg_diff($b) | mean_diff($) | aftertaxinc_diff(%) | |
---|---|---|---|---|
0-10n | 0.103662 | 0.000000 | 0.000000 | 0.000000 |
0-10z | 8.289516 | 0.000000 | 0.000000 | 0.000000 |
0-10p | 12.054047 | 0.000000 | 0.000000 | 0.000000 |
10-20 | 20.448097 | -0.335164 | -16.390966 | 0.109768 |
20-30 | 20.449272 | -1.023602 | -50.055659 | 0.190254 |
30-40 | 20.448454 | -1.245099 | -60.889648 | 0.174425 |
40-50 | 20.448974 | -1.696445 | -82.959903 | 0.192343 |
50-60 | 20.447937 | -2.635721 | -128.899109 | 0.241344 |
60-70 | 20.448353 | -3.662525 | -179.110988 | 0.267191 |
70-80 | 20.448556 | -4.814514 | -235.445159 | 0.278742 |
80-90 | 20.448771 | -8.040290 | -393.191831 | 0.354192 |
90-100 | 20.448526 | 24.994941 | 1222.334588 | -0.541295 |
ALL | 204.484164 | 1.541583 | 7.538885 | -0.011341 |
90-95 | 10.223657 | -5.532877 | -541.183722 | 0.365870 |
95-99 | 8.180007 | -2.628586 | -321.342681 | 0.147047 |
Top 1% | 2.044862 | 33.156403 | 16214.494881 | -2.516067 |