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.666
2020_REF_itax_rev($B)= 714.207
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.150 |
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.943 |
Regular Tax ($b) | 1457.696 |
AMT Income ($b) | 10791.922 |
AMT Liability ($b) | 0.436 |
AMT Filers (#m) | 0.080 |
Tax before Credits ($b) | 1458.132 |
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.666 |
Payroll Taxes ($b) | 1206.584 |
Combined Liability ($b) | 1919.249 |
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.150 |
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.314 |
Regular Tax ($b) | 1456.849 |
AMT Income ($b) | 10794.272 |
AMT Liability ($b) | 0.453 |
AMT Filers (#m) | 0.080 |
Tax before Credits ($b) | 1457.302 |
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.207 |
Payroll Taxes ($b) | 1206.584 |
Combined Liability ($b) | 1920.791 |
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.467047 | -6.467047 |
0-10z | 8.289516 | -17.339037 | -17.339037 | 17.339037 | 17.339037 |
0-10p | 12.054047 | -25.552744 | -25.552744 | 65.695218 | 65.695218 |
10-20 | 20.448097 | -52.575849 | -52.911012 | 305.337907 | 305.673071 |
20-30 | 20.449272 | -53.685654 | -54.709255 | 538.018415 | 539.042016 |
30-40 | 20.448454 | -47.247885 | -48.492983 | 713.830862 | 715.075961 |
40-50 | 20.448974 | -44.931163 | -46.627597 | 881.987948 | 883.684382 |
50-60 | 20.447937 | -40.474936 | -43.110651 | 1092.102654 | 1094.738369 |
60-70 | 20.448353 | -31.673547 | -35.336072 | 1370.752526 | 1374.415050 |
70-80 | 20.448556 | -0.391756 | -5.206269 | 1727.225856 | 1732.040369 |
80-90 | 20.448771 | 79.533006 | 71.492721 | 2270.037696 | 2278.077981 |
90-100 | 20.448526 | 947.297761 | 972.292702 | 4617.618129 | 4592.623188 |
ALL | 204.484164 | 712.665775 | 714.207380 | 13593.479200 | 13591.937595 |
90-95 | 10.223657 | 135.324101 | 129.791224 | 1512.249789 | 1517.782666 |
95-99 | 8.180007 | 311.466229 | 308.837644 | 1787.581674 | 1790.210259 |
Top 1% | 2.044862 | 500.507431 | 533.663834 | 1317.786666 | 1284.630262 |
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.335163 | -16.390935 | 0.109768 |
20-30 | 20.449272 | -1.023601 | -50.055622 | 0.190254 |
30-40 | 20.448454 | -1.245099 | -60.889634 | 0.174425 |
40-50 | 20.448974 | -1.696435 | -82.959397 | 0.192342 |
50-60 | 20.447937 | -2.635715 | -128.898822 | 0.241343 |
60-70 | 20.448353 | -3.662525 | -179.110981 | 0.267191 |
70-80 | 20.448556 | -4.814514 | -235.445159 | 0.278743 |
80-90 | 20.448771 | -8.040285 | -393.191612 | 0.354192 |
90-100 | 20.448526 | 24.994941 | 1222.334576 | -0.541295 |
ALL | 204.484164 | 1.541605 | 7.538994 | -0.011341 |
90-95 | 10.223657 | -5.532877 | -541.183719 | 0.365871 |
95-99 | 8.180007 | -2.628586 | -321.342684 | 0.147047 |
Top 1% | 2.044862 | 33.156403 | 16214.494762 | -2.516068 |