diff --git a/ppp.py b/ppp.py index 27e650138..a54d0cb66 100644 --- a/ppp.py +++ b/ppp.py @@ -1,98 +1,72 @@ """ -Policy parameter projection script, which calculates future policy parameter -values under TCJA and which should be used when the following happens: -(1) the inflation factor values change in growfactors.csv, or -(2) the last known historical values of policy parameters are updated, - in which case the byear parameter (see below) should be incremented. +Policy parameter projection script, which calculates policy parameter +values that were changed by TCJA and will revert to their pre-TCJA +values in 2026 (adjusted for inflation). The script should be run +when the inflation factor values change in growfactors.csv. + USAGE: $ python ppp.py -OUTPUT: ppp.old -- contains old parameter values in policy_current_law.json - ppp.new -- contains new parameter values that should now be used + +Note: running this script will write the new 2026 parameter values +directly to policy_current_law.json. """ -from taxcalc import Policy +from taxcalc import * +import json -# specify year constants (only byear should vary) -syear = Policy.JSON_START_YEAR -pyear = 2017 # prior year before TCJA first implemented -byear = 2019 # base year: year for last known historical parameter values -fyear = 2026 # final year in which parameter values revert to pre-TCJA values +params = Policy() -# ensure proper relationship between year constants -assert pyear == 2017 -assert fyear == 2026 -assert byear > pyear and byear < fyear +# parameters that will revert +long_params = ['II_brk7', 'II_brk6', 'II_brk5', 'II_brk4', + 'II_brk3', 'II_brk2', 'II_brk1', + 'PT_brk7', 'PT_brk6', 'PT_brk5', 'PT_brk4', + 'PT_brk3', 'PT_brk2', 'PT_brk1', + 'PT_qbid_taxinc_thd', + 'ALD_BusinessLosses_c', + 'STD', 'II_em', 'II_em_ps', + 'AMT_em', 'AMT_em_ps', 'AMT_em_pe', + 'ID_ps', 'ID_AllTaxes_c'] -# specify current-law policy that includes TCJA inflation indexing rules -clp = Policy() -pdata = clp._vals +# calculate the inflation factor used to calculate the +# inflation-adjusted 2026 parameter values +final_ifactor = 1.0 +pyear = 2017 # prior year before TCJA first implemented +fyear = 2026 # final year in which parameter values revert to +# pre-TCJA values +# construct final-year inflation factor from prior year +# NOTE: pvalue[t+1] = pvalue[t] * ( 1 + irate[t] ) +for year in range(pyear, fyear): + final_ifactor *= 1 + \ + params._inflation_rates[year - params.start_year] -# identify policy parameters that have their values reverted in final year -skip_list = ['_II_brk7', '_PT_brk7'] # because they are both "infinity" (9e99) -fyr = fyear -reverting_params = list() -for pname in sorted(pdata.keys()): - pdict = pdata[pname] - if pdata[pname]['indexed'] and fyr in pdata[pname]['value_yrs']: - if pname not in skip_list: - reverting_params.append(pname) -print('number_of_reverting_parameters= {}'.format(len(reverting_params))) +long_param_vals = defaultdict(list) -# write ppp.old containing existing values for reverting policy parameters -old = open('ppp.old', 'w') -for pname in reverting_params: - old.write('*** {} ***\n'.format(pname)) - # write parameter values for each year in [pyear,fyear] range - for year in range(pyear, fyear + 1): - value = pdata[pname]['value'][year - syear] - old.write('{}: {}\n'.format(year, value)) -old.close() +for param in long_params: + vos = params.select_eq(param, year=pyear) + # use final_ifactor to inflate from 2017 to 2026 + for vo in vos: + long_param_vals[param].append( + # Create new dict to avoid modifying the original + dict( + vo, + value=min(9e99, round( + vo["value"] * final_ifactor, 0)), + year=fyear, + ) + ) -# get TCJA parameter inflation rates for each year -irate = clp.inflation_rates() +# call adjust method for new 2026 values +params.adjust(long_param_vals) +params.clear_state() +param_data = params.specification( + meta_data=False, serializable=True, use_state=False, _auto=False) -# construct final-year inflation factor from prior year -# < NOTE: pvalue[t+1] = pvalue[t] * ( 1 + irate[t] ) > -final_ifactor = 1.0 -for year in range(pyear, fyear): - final_ifactor *= 1 + irate[year - syear] +# read existing policy_current_law.json +with open('taxcalc/policy_current_law.json', 'r') as f: + pcl = json.load(f) -# construct intermediate-year inflation factors from base year -# < NOTE: pvalue[t+1] = pvalue[t] * ( 1 + irate[t] ) > -ifactor = dict() -factor = 1.0 -for year in range(byear, fyear): - ifactor[year] = factor - factor *= 1 + irate[year - syear] +# replace 2026 values in policy_current_law.json +for param in param_data: + pcl[param]["value"] = param_data[param] -# write or calculate policy parameter values for pyear through fyear -new = open('ppp.new', 'w') -for pname in reverting_params: - new.write('*** {} ***\n'.format(pname)) - # write parameter values for prior year - value = pdata[pname]['value'][pyear - syear] - new.write('{}: {}\n'.format(pyear, value)) - # write parameter values for year after prior year up through base year - for year in range(pyear + 1, byear + 1): - value = pdata[pname]['value'][year - syear] - new.write('{}: {}\n'.format(year, value)) - # compute parameter values for intermediate years - bvalue = pdata[pname]['value'][byear - syear] - for year in range(byear + 1, fyear): - if isinstance(bvalue, list): - value = list() - for idx in range(0, len(bvalue)): - val = min(9e99, round(bvalue[idx] * ifactor[year], 2)) - value.append(val) - else: - value = min(9e99, round(bvalue * ifactor[year], 2)) - new.write('{}: {}\n'.format(year, value)) - # compute final year parameter value - pvalue = pdata[pname]['value'][pyear - syear] - if isinstance(pvalue, list): - value = list() - for idx in range(0, len(pvalue)): - val = min(9e99, round(pvalue[idx] * final_ifactor, 0)) - value.append(val) - else: - value = min(9e99, round(pvalue * final_ifactor, 0)) - new.write('{}: {}\n'.format(fyear, value)) -new.close() +# write new policy_current_law.json +with open('taxcalc/policy_current_law.json', 'w') as pcl_old: + json.dump(pcl, pcl_old, indent=4) diff --git a/taxcalc/policy_current_law.json b/taxcalc/policy_current_law.json index 0b9cc9550..9d8c17e8d 100644 --- a/taxcalc/policy_current_law.json +++ b/taxcalc/policy_current_law.json @@ -1547,27 +1547,27 @@ { "year": 2026, "MARS": "single", - "value": 316457.0 + "value": 315093.0 }, { "year": 2026, "MARS": "mjoint", - "value": 379748.0 + "value": 378112.0 }, { "year": 2026, "MARS": "mseparate", - "value": 189874.0 + "value": 189056.0 }, { "year": 2026, "MARS": "headhh", - "value": 348102.0 + "value": 346603.0 }, { "year": 2026, "MARS": "widow", - "value": 379748.0 + "value": 378112.0 } ], "validators": { @@ -5778,38 +5778,38 @@ "value": [ { "year": 2013, - "idedtype": "med", - "value": true + "value": true, + "idedtype": "med" }, { "year": 2013, - "idedtype": "sltx", - "value": true + "value": true, + "idedtype": "sltx" }, { "year": 2013, - "idedtype": "retx", - "value": true + "value": true, + "idedtype": "retx" }, { "year": 2013, - "idedtype": "cas", - "value": true + "value": true, + "idedtype": "cas" }, { "year": 2013, - "idedtype": "misc", - "value": true + "value": true, + "idedtype": "misc" }, { "year": 2013, - "idedtype": "int", - "value": true + "value": true, + "idedtype": "int" }, { "year": 2013, - "idedtype": "char", - "value": true + "value": true, + "idedtype": "char" } ], "validators": { @@ -5861,38 +5861,38 @@ "value": [ { "year": 2013, - "idedtype": "med", - "value": true + "value": true, + "idedtype": "med" }, { "year": 2013, - "idedtype": "sltx", - "value": true + "value": true, + "idedtype": "sltx" }, { "year": 2013, - "idedtype": "retx", - "value": true + "value": true, + "idedtype": "retx" }, { "year": 2013, - "idedtype": "cas", - "value": true + "value": true, + "idedtype": "cas" }, { "year": 2013, - "idedtype": "misc", - "value": true + "value": true, + "idedtype": "misc" }, { "year": 2013, - "idedtype": "int", - "value": true + "value": true, + "idedtype": "int" }, { "year": 2013, - "idedtype": "char", - "value": true + "value": true, + "idedtype": "char" } ], "validators": { @@ -6141,38 +6141,38 @@ "value": [ { "year": 2013, - "idedtype": "med", - "value": true + "value": true, + "idedtype": "med" }, { "year": 2013, - "idedtype": "sltx", - "value": true + "value": true, + "idedtype": "sltx" }, { "year": 2013, - "idedtype": "retx", - "value": true + "value": true, + "idedtype": "retx" }, { "year": 2013, - "idedtype": "cas", - "value": true + "value": true, + "idedtype": "cas" }, { "year": 2013, - "idedtype": "misc", - "value": true + "value": true, + "idedtype": "misc" }, { "year": 2013, - "idedtype": "int", - "value": true + "value": true, + "idedtype": "int" }, { "year": 2013, - "idedtype": "char", - "value": true + "value": true, + "idedtype": "char" } ], "validators": { diff --git a/taxcalc/tests/cpscsv_agg_expect.csv b/taxcalc/tests/cpscsv_agg_expect.csv index 78e3e433e..c124a7b8a 100644 --- a/taxcalc/tests/cpscsv_agg_expect.csv +++ b/taxcalc/tests/cpscsv_agg_expect.csv @@ -5,11 +5,11 @@ Itemizers (#m),67.8,28.8,30.5,31.8,32.6,33.7,34.7,35.9,37.0,83.4 Itemized Deduction ($b),1339.1,734.2,792.6,843.5,876.2,925.7,977.6,1034.0,1093.6,2112.2 Standard Deduction Filers (#m),129.2,171.1,172.2,173.6,175.5,177.1,178.8,180.4,182.0,138.3 Standard Deduction ($b),1224.7,3016.4,3088.8,3165.1,3272.2,3380.4,3493.8,3605.0,3717.8,1602.1 -Personal Exemption ($b),1482.3,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1982.6 -Taxable Income ($b),7471.8,8388.7,8855.1,9275.7,9725.8,10138.2,10523.4,10938.3,11367.3,11135.9 -Regular Tax ($b),1482.0,1496.5,1586.0,1670.9,1759.1,1838.9,1912.1,1991.8,2074.6,2274.5 +Personal Exemption ($b),1482.3,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1982.3 +Taxable Income ($b),7471.8,8388.7,8855.1,9275.7,9725.8,10138.2,10523.4,10938.3,11367.3,11136.2 +Regular Tax ($b),1482.0,1496.5,1586.0,1670.9,1759.1,1838.9,1912.1,1991.8,2074.6,2274.6 AMT Income ($b),9689.2,10621.1,11140.6,11614.2,12142.1,12629.0,13092.4,13583.5,14089.0,14116.4 -AMT Liability ($b),10.8,0.8,1.0,1.0,1.0,1.0,0.9,0.9,0.9,16.6 +AMT Liability ($b),10.8,0.8,1.0,1.0,1.0,1.0,0.9,0.9,0.9,16.5 AMT Filers (#m),3.4,0.2,0.4,0.4,0.4,0.4,0.4,0.4,0.4,4.5 Tax before Credits ($b),1492.9,1497.2,1586.9,1671.8,1760.0,1839.9,1913.1,1992.7,2075.5,2291.1 Refundable Credits ($b),82.1,96.6,96.5,96.0,96.4,98.1,99.2,100.3,102.0,88.2 @@ -18,7 +18,7 @@ Reform Surtaxes ($b),0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 Other Taxes ($b),12.4,13.6,14.4,15.1,16.0,16.9,17.4,18.4,19.5,20.7 Ind Income Tax ($b),1389.9,1318.6,1407.2,1491.5,1578.6,1656.4,1727.7,1806.1,1887.4,2193.5 Payroll Taxes ($b),1104.5,1156.3,1213.0,1269.6,1327.1,1381.0,1433.0,1485.5,1538.7,1594.0 -Combined Liability ($b),2494.4,2474.9,2620.2,2761.1,2905.7,3037.3,3160.7,3291.6,3426.1,3787.4 +Combined Liability ($b),2494.4,2474.9,2620.2,2761.1,2905.7,3037.3,3160.7,3291.6,3426.1,3787.5 With Income Tax <= 0 (#m),92.2,96.8,97.3,98.0,98.6,99.5,100.4,101.3,102.3,100.4 With Combined Tax <= 0 (#m),63.7,66.3,67.2,68.1,69.1,70.2,71.3,72.3,73.4,72.9 UBI Benefits ($b),0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 diff --git a/taxcalc/tests/pufcsv_agg_expect.csv b/taxcalc/tests/pufcsv_agg_expect.csv index 47d95d4d1..aad46dc26 100644 --- a/taxcalc/tests/pufcsv_agg_expect.csv +++ b/taxcalc/tests/pufcsv_agg_expect.csv @@ -5,11 +5,11 @@ Itemizers (#m),46.2,20.8,21.8,22.4,22.3,22.8,23.2,23.6,24.0,54.4 Itemized Deduction ($b),1306.5,653.5,692.3,727.6,737.7,770.8,804.4,839.9,876.7,1974.8 Standard Deduction Filers (#m),123.7,152.0,153.4,155.1,157.4,159.2,161.1,162.8,164.6,136.5 Standard Deduction ($b),1096.2,2579.0,2651.3,2722.8,2828.0,2925.7,3030.3,3131.2,3237.2,1471.3 -Personal Exemption ($b),1253.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1639.0 -Taxable Income ($b),8228.4,9296.8,9784.3,10227.7,10690.3,11103.3,11508.6,11944.2,12388.3,12069.5 -Regular Tax ($b),1680.2,1733.6,1827.6,1920.8,2012.8,2093.1,2172.1,2257.6,2344.0,2512.2 +Personal Exemption ($b),1253.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1638.6 +Taxable Income ($b),8228.4,9296.8,9784.3,10227.7,10690.3,11103.3,11508.6,11944.2,12388.3,12069.8 +Regular Tax ($b),1680.2,1733.6,1827.6,1920.8,2012.8,2093.1,2172.1,2257.6,2344.0,2512.3 AMT Income ($b),10708.4,11605.2,12150.6,12661.9,13216.2,13714.9,14213.3,14738.4,15273.0,15467.1 -AMT Liability ($b),50.1,23.0,24.3,25.4,26.5,27.5,28.7,29.8,31.2,78.1 +AMT Liability ($b),50.1,23.0,24.3,25.4,26.5,27.5,28.7,29.8,31.2,78.0 AMT Filers (#m),5.4,0.5,1.2,1.2,1.2,1.2,1.2,1.2,1.2,7.5 Tax before Credits ($b),1730.2,1756.6,1851.9,1946.2,2039.3,2120.6,2200.8,2287.5,2375.2,2590.3 Refundable Credits ($b),104.6,120.0,120.8,120.8,121.9,124.6,126.6,128.4,131.4,116.6