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)= 748.768
2020_REF_itax_rev($B)= 750.713
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) | 11529.507 |
Itemizers (#m) | 27.130 |
Itemized Deduction ($b) | 734.486 |
Standard Deduction Filers (#m) | 177.360 |
Standard Deduction ($b) | 3087.473 |
Personal Exemption ($b) | 0.000 |
Taxable Income ($b) | 8559.022 |
Regular Tax ($b) | 1491.329 |
AMT Income ($b) | 10982.328 |
AMT Liability ($b) | 0.557 |
AMT Filers (#m) | 0.090 |
Tax before Credits ($b) | 1491.886 |
Refundable Credits ($b) | 655.173 |
Nonrefundable Credits ($b) | 99.323 |
Reform Surtaxes ($b) | 0.000 |
Other Taxes ($b) | 11.379 |
Ind Income Tax ($b) | 748.768 |
Payroll Taxes ($b) | 1217.120 |
Combined Liability ($b) | 1965.888 |
With Income Tax <= 0 (#m) | 135.340 |
With Combined Tax <= 0 (#m) | 98.260 |
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) | 11529.507 |
Itemizers (#m) | 27.060 |
Itemized Deduction ($b) | 732.100 |
Standard Deduction Filers (#m) | 177.430 |
Standard Deduction ($b) | 3088.674 |
Personal Exemption ($b) | 375.177 |
Taxable Income ($b) | 8311.506 |
Regular Tax ($b) | 1490.903 |
AMT Income ($b) | 10984.562 |
AMT Liability ($b) | 0.576 |
AMT Filers (#m) | 0.090 |
Tax before Credits ($b) | 1491.479 |
Refundable Credits ($b) | 658.503 |
Nonrefundable Credits ($b) | 93.641 |
Reform Surtaxes ($b) | 0.000 |
Other Taxes ($b) | 11.379 |
Ind Income Tax ($b) | 750.713 |
Payroll Taxes ($b) | 1217.120 |
Combined Liability ($b) | 1967.833 |
With Income Tax <= 0 (#m) | 137.500 |
With Combined Tax <= 0 (#m) | 99.030 |
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.297969 | -6.297969 |
0-10z | 8.289516 | -17.339037 | -17.339037 | 17.339037 | 17.339037 |
0-10p | 12.054989 | -25.566551 | -25.566551 | 66.334174 | 66.334174 |
10-20 | 20.448308 | -52.534361 | -52.880017 | 308.094572 | 308.440227 |
20-30 | 20.448602 | -53.521518 | -54.539659 | 542.208482 | 543.226622 |
30-40 | 20.448013 | -46.789066 | -48.048532 | 717.150220 | 718.409686 |
40-50 | 20.447490 | -44.628027 | -46.340104 | 887.036161 | 888.748238 |
50-60 | 20.449058 | -39.688636 | -42.353582 | 1098.344015 | 1101.008961 |
60-70 | 20.448335 | -30.823607 | -34.513147 | 1379.374777 | 1383.064317 |
70-80 | 20.448828 | 1.762567 | -3.073536 | 1739.462883 | 1744.298986 |
80-90 | 20.448762 | 83.792137 | 75.612308 | 2287.028069 | 2295.207898 |
90-100 | 20.448603 | 974.396964 | 1000.047566 | 4704.330451 | 4678.679850 |
ALL | 204.484164 | 748.768441 | 750.713285 | 13740.404872 | 13738.460028 |
90-95 | 10.224126 | 140.502650 | 134.936437 | 1526.388799 | 1531.955012 |
95-99 | 8.179595 | 320.894731 | 318.503022 | 1814.414424 | 1816.806134 |
Top 1% | 2.044882 | 512.999583 | 546.608107 | 1363.527228 | 1329.918704 |
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.054989 | 0.000000 | 0.000000 | 0.000000 |
10-20 | 20.448308 | -0.345655 | -16.903847 | 0.112191 |
20-30 | 20.448602 | -1.018141 | -49.790242 | 0.187777 |
30-40 | 20.448013 | -1.259466 | -61.593571 | 0.175621 |
40-50 | 20.447490 | -1.712077 | -83.730428 | 0.193011 |
50-60 | 20.449058 | -2.664946 | -130.321236 | 0.242633 |
60-70 | 20.448335 | -3.689540 | -180.432288 | 0.267479 |
70-80 | 20.448828 | -4.836103 | -236.497826 | 0.278023 |
80-90 | 20.448762 | -8.179829 | -400.015858 | 0.357662 |
90-100 | 20.448603 | 25.650602 | 1254.393851 | -0.545255 |
ALL | 204.484164 | 1.944844 | 9.510975 | -0.014154 |
90-95 | 10.224126 | -5.566213 | -544.419489 | 0.364665 |
95-99 | 8.179595 | -2.391709 | -292.399482 | 0.131817 |
Top 1% | 2.044882 | 33.608524 | 16435.432685 | -2.464822 |