From 7557f060ef43bf5ff7e31005256a7665bc8ff17d Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Tue, 9 Jul 2024 10:16:37 +0100 Subject: [PATCH 1/6] Fix QBI deduction --- tax_microdata_benchmarking/utils/soi_targets.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tax_microdata_benchmarking/utils/soi_targets.py b/tax_microdata_benchmarking/utils/soi_targets.py index 85b8aa1a..43dab20d 100644 --- a/tax_microdata_benchmarking/utils/soi_targets.py +++ b/tax_microdata_benchmarking/utils/soi_targets.py @@ -242,6 +242,17 @@ def clean_soi_file(soi): soi = soi.groupby(unique_columns).first().reset_index() + soi[soi.Year == 2021][ + soi.Variable == "partnership_and_s_corp_income" + ] += soi[soi.Year == 2021][soi.Variable == "s_corporation_net_income"] + + soi[soi.Year == 2021][ + soi.Variable == "partnership_and_s_corp_losses" + ] += soi[soi.Year == 2021][soi.Variable == "s_corporation_net_losses"] + + soi = soi[soi.Variable != "s_corporation_net_income"] + soi = soi[soi.Variable != "s_corporation_net_losses"] + return soi[columns] From eaafbea216eba1dbe6951f21b514783bfb055842 Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Tue, 9 Jul 2024 11:51:40 +0100 Subject: [PATCH 2/6] Fix soi targets (strange dataframe issue) --- .../storage/input/soi.csv | 276 +++++++++--------- .../utils/soi_targets.py | 21 +- 2 files changed, 145 insertions(+), 152 deletions(-) diff --git a/tax_microdata_benchmarking/storage/input/soi.csv b/tax_microdata_benchmarking/storage/input/soi.csv index 5a4a2fc8..aec36aeb 100644 --- a/tax_microdata_benchmarking/storage/input/soi.csv +++ b/tax_microdata_benchmarking/storage/input/soi.csv @@ -4043,150 +4043,150 @@ Year,SOI table,XLSX column,XLSX row,Variable,Filing status,AGI lower bound,AGI u 2021,Table 1.4,L,27,ordinary_dividends,All,5000000.0,10000000.0,True,False,False,58225 2021,Table 1.4,M,28,ordinary_dividends,All,10000000.0,inf,False,False,False,83529618000 2021,Table 1.4,L,28,ordinary_dividends,All,10000000.0,inf,True,False,False,42967 -2021,Table 1.4,BE,10,partnership_and_s_corp_income,All,-inf,0.0,False,False,False,3495518000 -2021,Table 1.4,BE,30,partnership_and_s_corp_income,All,-inf,0.0,False,True,False,879264000 -2021,Table 1.4,BD,10,partnership_and_s_corp_income,All,-inf,0.0,True,False,False,51367 -2021,Table 1.4,BD,30,partnership_and_s_corp_income,All,-inf,0.0,True,True,False,854 -2021,Table 1.4,BE,9,partnership_and_s_corp_income,All,-inf,inf,False,False,True,469816308000 -2021,Table 1.4,BE,29,partnership_and_s_corp_income,All,-inf,inf,False,True,False,460036489000 -2021,Table 1.4,BD,9,partnership_and_s_corp_income,All,-inf,inf,True,False,True,3201572 -2021,Table 1.4,BD,29,partnership_and_s_corp_income,All,-inf,inf,True,True,False,2798300 -2021,Table 1.4,BE,11,partnership_and_s_corp_income,All,1.0,5000.0,False,False,False,191043000 -2021,Table 1.4,BE,31,partnership_and_s_corp_income,All,1.0,5000.0,False,True,False,24490000 -2021,Table 1.4,BD,11,partnership_and_s_corp_income,All,1.0,5000.0,True,False,False,27783 -2021,Table 1.4,BD,31,partnership_and_s_corp_income,All,1.0,5000.0,True,True,False,7025 -2021,Table 1.4,BE,12,partnership_and_s_corp_income,All,5000.0,10000.0,False,False,False,238826000 +2021,Table 1.4,BE,10,partnership_and_s_corp_income,All,-inf,0.0,False,False,False,7887066000 +2021,Table 1.4,BE,30,partnership_and_s_corp_income,All,-inf,0.0,False,True,False,1694393000 +2021,Table 1.4,BD,10,partnership_and_s_corp_income,All,-inf,0.0,True,False,False,81198 +2021,Table 1.4,BD,30,partnership_and_s_corp_income,All,-inf,0.0,True,True,False,1426 +2021,Table 1.4,BE,9,partnership_and_s_corp_income,All,-inf,inf,False,False,True,1236497548000 +2021,Table 1.4,BE,29,partnership_and_s_corp_income,All,-inf,inf,False,True,False,1212740035000 +2021,Table 1.4,BD,9,partnership_and_s_corp_income,All,-inf,inf,True,False,True,7080387 +2021,Table 1.4,BD,29,partnership_and_s_corp_income,All,-inf,inf,True,True,False,6224602 +2021,Table 1.4,BE,11,partnership_and_s_corp_income,All,1.0,5000.0,False,False,False,283607000 +2021,Table 1.4,BE,31,partnership_and_s_corp_income,All,1.0,5000.0,False,True,False,116177000 +2021,Table 1.4,BD,11,partnership_and_s_corp_income,All,1.0,5000.0,True,False,False,47856 +2021,Table 1.4,BD,31,partnership_and_s_corp_income,All,1.0,5000.0,True,True,False,11339 +2021,Table 1.4,BE,12,partnership_and_s_corp_income,All,5000.0,10000.0,False,False,False,586238000 2021,Table 1.4,BE,32,partnership_and_s_corp_income,All,5000.0,10000.0,False,True,False,0 -2021,Table 1.4,BD,12,partnership_and_s_corp_income,All,5000.0,10000.0,True,False,False,32994 +2021,Table 1.4,BD,12,partnership_and_s_corp_income,All,5000.0,10000.0,True,False,False,68157 2021,Table 1.4,BD,32,partnership_and_s_corp_income,All,5000.0,10000.0,True,True,False,0 -2021,Table 1.4,BE,13,partnership_and_s_corp_income,All,10000.0,15000.0,False,False,False,456672000 -2021,Table 1.4,BE,33,partnership_and_s_corp_income,All,10000.0,15000.0,False,True,False,65988000 -2021,Table 1.4,BD,13,partnership_and_s_corp_income,All,10000.0,15000.0,True,False,False,47844 -2021,Table 1.4,BD,33,partnership_and_s_corp_income,All,10000.0,15000.0,True,True,False,8165 -2021,Table 1.4,BE,14,partnership_and_s_corp_income,All,15000.0,20000.0,False,False,False,510981000 -2021,Table 1.4,BE,34,partnership_and_s_corp_income,All,15000.0,20000.0,False,True,False,113367000 -2021,Table 1.4,BD,14,partnership_and_s_corp_income,All,15000.0,20000.0,True,False,False,47049 -2021,Table 1.4,BD,34,partnership_and_s_corp_income,All,15000.0,20000.0,True,True,False,11878 -2021,Table 1.4,BE,15,partnership_and_s_corp_income,All,20000.0,25000.0,False,False,False,526263000 -2021,Table 1.4,BE,35,partnership_and_s_corp_income,All,20000.0,25000.0,False,True,False,138113000 -2021,Table 1.4,BD,15,partnership_and_s_corp_income,All,20000.0,25000.0,True,False,False,45301 -2021,Table 1.4,BD,35,partnership_and_s_corp_income,All,20000.0,25000.0,True,True,False,11568 -2021,Table 1.4,BE,16,partnership_and_s_corp_income,All,25000.0,30000.0,False,False,False,853533000 -2021,Table 1.4,BE,36,partnership_and_s_corp_income,All,25000.0,30000.0,False,True,False,392260000 -2021,Table 1.4,BD,16,partnership_and_s_corp_income,All,25000.0,30000.0,True,False,False,48690 -2021,Table 1.4,BD,36,partnership_and_s_corp_income,All,25000.0,30000.0,True,True,False,26536 -2021,Table 1.4,BE,17,partnership_and_s_corp_income,All,30000.0,40000.0,False,False,False,1429379000 -2021,Table 1.4,BE,37,partnership_and_s_corp_income,All,30000.0,40000.0,False,True,False,735697000 -2021,Table 1.4,BD,17,partnership_and_s_corp_income,All,30000.0,40000.0,True,False,False,89514 -2021,Table 1.4,BD,37,partnership_and_s_corp_income,All,30000.0,40000.0,True,True,False,50314 -2021,Table 1.4,BE,18,partnership_and_s_corp_income,All,40000.0,50000.0,False,False,False,1915933000 -2021,Table 1.4,BE,38,partnership_and_s_corp_income,All,40000.0,50000.0,False,True,False,1349393000 -2021,Table 1.4,BD,18,partnership_and_s_corp_income,All,40000.0,50000.0,True,False,False,100861 -2021,Table 1.4,BD,38,partnership_and_s_corp_income,All,40000.0,50000.0,True,True,False,73906 -2021,Table 1.4,BE,19,partnership_and_s_corp_income,All,50000.0,75000.0,False,False,False,5029213000 -2021,Table 1.4,BE,39,partnership_and_s_corp_income,All,50000.0,75000.0,False,True,False,3828802000 -2021,Table 1.4,BD,19,partnership_and_s_corp_income,All,50000.0,75000.0,True,False,False,255645 -2021,Table 1.4,BD,39,partnership_and_s_corp_income,All,50000.0,75000.0,True,True,False,206561 -2021,Table 1.4,BE,20,partnership_and_s_corp_income,All,75000.0,100000.0,False,False,False,6041749000 -2021,Table 1.4,BE,40,partnership_and_s_corp_income,All,75000.0,100000.0,False,True,False,5185499000 -2021,Table 1.4,BD,20,partnership_and_s_corp_income,All,75000.0,100000.0,True,False,False,234635 -2021,Table 1.4,BD,40,partnership_and_s_corp_income,All,75000.0,100000.0,True,True,False,210664 -2021,Table 1.4,BE,21,partnership_and_s_corp_income,All,100000.0,200000.0,False,False,False,26438754000 -2021,Table 1.4,BE,41,partnership_and_s_corp_income,All,100000.0,200000.0,False,True,False,25256034000 -2021,Table 1.4,BD,21,partnership_and_s_corp_income,All,100000.0,200000.0,True,False,False,761877 -2021,Table 1.4,BD,41,partnership_and_s_corp_income,All,100000.0,200000.0,True,True,False,736185 -2021,Table 1.4,BE,22,partnership_and_s_corp_income,All,200000.0,500000.0,False,False,False,63894659000 -2021,Table 1.4,BE,42,partnership_and_s_corp_income,All,200000.0,500000.0,False,True,False,63464072000 -2021,Table 1.4,BD,22,partnership_and_s_corp_income,All,200000.0,500000.0,True,False,False,789328 -2021,Table 1.4,BD,42,partnership_and_s_corp_income,All,200000.0,500000.0,True,True,False,786186 -2021,Table 1.4,BE,23,partnership_and_s_corp_income,All,500000.0,1000000.0,False,False,False,72964993000 -2021,Table 1.4,BE,43,partnership_and_s_corp_income,All,500000.0,1000000.0,False,True,False,72923669000 -2021,Table 1.4,BD,23,partnership_and_s_corp_income,All,500000.0,1000000.0,True,False,False,352610 -2021,Table 1.4,BD,43,partnership_and_s_corp_income,All,500000.0,1000000.0,True,True,False,352510 -2021,Table 1.4,BE,24,partnership_and_s_corp_income,All,1000000.0,1500000.0,False,False,False,42314661000 -2021,Table 1.4,BD,24,partnership_and_s_corp_income,All,1000000.0,1500000.0,True,False,False,117686 -2021,Table 1.4,BE,44,partnership_and_s_corp_income,All,1000000.0,inf,False,True,False,285679840000 -2021,Table 1.4,BD,44,partnership_and_s_corp_income,All,1000000.0,inf,True,True,False,315949 -2021,Table 1.4,BE,25,partnership_and_s_corp_income,All,1500000.0,2000000.0,False,False,False,26983310000 -2021,Table 1.4,BD,25,partnership_and_s_corp_income,All,1500000.0,2000000.0,True,False,False,55237 -2021,Table 1.4,BE,26,partnership_and_s_corp_income,All,2000000.0,5000000.0,False,False,False,75076603000 -2021,Table 1.4,BD,26,partnership_and_s_corp_income,All,2000000.0,5000000.0,True,False,False,93799 -2021,Table 1.4,BE,27,partnership_and_s_corp_income,All,5000000.0,10000000.0,False,False,False,42960677000 -2021,Table 1.4,BD,27,partnership_and_s_corp_income,All,5000000.0,10000000.0,True,False,False,28090 -2021,Table 1.4,BE,28,partnership_and_s_corp_income,All,10000000.0,inf,False,False,False,98493540000 -2021,Table 1.4,BD,28,partnership_and_s_corp_income,All,10000000.0,inf,True,False,False,21260 -2021,Table 1.4,BG,10,partnership_and_s_corp_losses,All,-inf,0.0,False,False,False,41556919000 -2021,Table 1.4,BG,30,partnership_and_s_corp_losses,All,-inf,0.0,False,True,False,2364763000 -2021,Table 1.4,BF,10,partnership_and_s_corp_losses,All,-inf,0.0,True,False,False,154045 -2021,Table 1.4,BF,30,partnership_and_s_corp_losses,All,-inf,0.0,True,True,False,1104 -2021,Table 1.4,BG,9,partnership_and_s_corp_losses,All,-inf,inf,False,False,True,168152043000 -2021,Table 1.4,BG,29,partnership_and_s_corp_losses,All,-inf,inf,False,True,False,120188214000 -2021,Table 1.4,BF,9,partnership_and_s_corp_losses,All,-inf,inf,True,False,True,1990357 -2021,Table 1.4,BF,29,partnership_and_s_corp_losses,All,-inf,inf,True,True,False,1587897 -2021,Table 1.4,BG,11,partnership_and_s_corp_losses,All,1.0,5000.0,False,False,False,280618000 -2021,Table 1.4,BG,31,partnership_and_s_corp_losses,All,1.0,5000.0,False,True,False,0 -2021,Table 1.4,BF,11,partnership_and_s_corp_losses,All,1.0,5000.0,True,False,False,20109 -2021,Table 1.4,BF,31,partnership_and_s_corp_losses,All,1.0,5000.0,True,True,False,0 -2021,Table 1.4,BG,12,partnership_and_s_corp_losses,All,5000.0,10000.0,False,False,False,483055000 +2021,Table 1.4,BE,13,partnership_and_s_corp_income,All,10000.0,15000.0,False,False,False,909688000 +2021,Table 1.4,BE,33,partnership_and_s_corp_income,All,10000.0,15000.0,False,True,False,89827000 +2021,Table 1.4,BD,13,partnership_and_s_corp_income,All,10000.0,15000.0,True,False,False,80211 +2021,Table 1.4,BD,33,partnership_and_s_corp_income,All,10000.0,15000.0,True,True,False,10498 +2021,Table 1.4,BE,14,partnership_and_s_corp_income,All,15000.0,20000.0,False,False,False,1103007000 +2021,Table 1.4,BE,34,partnership_and_s_corp_income,All,15000.0,20000.0,False,True,False,398008000 +2021,Table 1.4,BD,14,partnership_and_s_corp_income,All,15000.0,20000.0,True,False,False,103979 +2021,Table 1.4,BD,34,partnership_and_s_corp_income,All,15000.0,20000.0,True,True,False,35371 +2021,Table 1.4,BE,15,partnership_and_s_corp_income,All,20000.0,25000.0,False,False,False,1305887000 +2021,Table 1.4,BE,35,partnership_and_s_corp_income,All,20000.0,25000.0,False,True,False,621762000 +2021,Table 1.4,BD,15,partnership_and_s_corp_income,All,20000.0,25000.0,True,False,False,102791 +2021,Table 1.4,BD,35,partnership_and_s_corp_income,All,20000.0,25000.0,True,True,False,43185 +2021,Table 1.4,BE,16,partnership_and_s_corp_income,All,25000.0,30000.0,False,False,False,1922619000 +2021,Table 1.4,BE,36,partnership_and_s_corp_income,All,25000.0,30000.0,False,True,False,1032511000 +2021,Table 1.4,BD,16,partnership_and_s_corp_income,All,25000.0,30000.0,True,False,False,115715 +2021,Table 1.4,BD,36,partnership_and_s_corp_income,All,25000.0,30000.0,True,True,False,64290 +2021,Table 1.4,BE,17,partnership_and_s_corp_income,All,30000.0,40000.0,False,False,False,3983255000 +2021,Table 1.4,BE,37,partnership_and_s_corp_income,All,30000.0,40000.0,False,True,False,2199313000 +2021,Table 1.4,BD,17,partnership_and_s_corp_income,All,30000.0,40000.0,True,False,False,236011 +2021,Table 1.4,BD,37,partnership_and_s_corp_income,All,30000.0,40000.0,True,True,False,130894 +2021,Table 1.4,BE,18,partnership_and_s_corp_income,All,40000.0,50000.0,False,False,False,4619794000 +2021,Table 1.4,BE,38,partnership_and_s_corp_income,All,40000.0,50000.0,False,True,False,3281175000 +2021,Table 1.4,BD,18,partnership_and_s_corp_income,All,40000.0,50000.0,True,False,False,228209 +2021,Table 1.4,BD,38,partnership_and_s_corp_income,All,40000.0,50000.0,True,True,False,168315 +2021,Table 1.4,BE,19,partnership_and_s_corp_income,All,50000.0,75000.0,False,False,False,15009727000 +2021,Table 1.4,BE,39,partnership_and_s_corp_income,All,50000.0,75000.0,False,True,False,11435042000 +2021,Table 1.4,BD,19,partnership_and_s_corp_income,All,50000.0,75000.0,True,False,False,606696 +2021,Table 1.4,BD,39,partnership_and_s_corp_income,All,50000.0,75000.0,True,True,False,479345 +2021,Table 1.4,BE,20,partnership_and_s_corp_income,All,75000.0,100000.0,False,False,False,18667765000 +2021,Table 1.4,BE,40,partnership_and_s_corp_income,All,75000.0,100000.0,False,True,False,15792920000 +2021,Table 1.4,BD,20,partnership_and_s_corp_income,All,75000.0,100000.0,True,False,False,578825 +2021,Table 1.4,BD,40,partnership_and_s_corp_income,All,75000.0,100000.0,True,True,False,507611 +2021,Table 1.4,BE,21,partnership_and_s_corp_income,All,100000.0,200000.0,False,False,False,78156489000 +2021,Table 1.4,BE,41,partnership_and_s_corp_income,All,100000.0,200000.0,False,True,False,75244854000 +2021,Table 1.4,BD,21,partnership_and_s_corp_income,All,100000.0,200000.0,True,False,False,1785491 +2021,Table 1.4,BD,41,partnership_and_s_corp_income,All,100000.0,200000.0,True,True,False,1732549 +2021,Table 1.4,BE,22,partnership_and_s_corp_income,All,200000.0,500000.0,False,False,False,181930698000 +2021,Table 1.4,BE,42,partnership_and_s_corp_income,All,200000.0,500000.0,False,True,False,181003241000 +2021,Table 1.4,BD,22,partnership_and_s_corp_income,All,200000.0,500000.0,True,False,False,1753402 +2021,Table 1.4,BD,42,partnership_and_s_corp_income,All,200000.0,500000.0,True,True,False,1748290 +2021,Table 1.4,BE,23,partnership_and_s_corp_income,All,500000.0,1000000.0,False,False,False,173728789000 +2021,Table 1.4,BE,43,partnership_and_s_corp_income,All,500000.0,1000000.0,False,True,False,173652500000 +2021,Table 1.4,BD,23,partnership_and_s_corp_income,All,500000.0,1000000.0,True,False,False,694433 +2021,Table 1.4,BD,43,partnership_and_s_corp_income,All,500000.0,1000000.0,True,True,False,694255 +2021,Table 1.4,BE,24,partnership_and_s_corp_income,All,1000000.0,1500000.0,False,False,False,104846418000 +2021,Table 1.4,BD,24,partnership_and_s_corp_income,All,1000000.0,1500000.0,True,False,False,227981 +2021,Table 1.4,BE,44,partnership_and_s_corp_income,All,1000000.0,inf,False,True,False,746178311000 +2021,Table 1.4,BD,44,partnership_and_s_corp_income,All,1000000.0,inf,True,True,False,597235 +2021,Table 1.4,BE,25,partnership_and_s_corp_income,All,1500000.0,2000000.0,False,False,False,69068636000 +2021,Table 1.4,BD,25,partnership_and_s_corp_income,All,1500000.0,2000000.0,True,False,False,105458 +2021,Table 1.4,BE,26,partnership_and_s_corp_income,All,2000000.0,5000000.0,False,False,False,191186000000 +2021,Table 1.4,BD,26,partnership_and_s_corp_income,All,2000000.0,5000000.0,True,False,False,174470 +2021,Table 1.4,BE,27,partnership_and_s_corp_income,All,5000000.0,10000000.0,False,False,False,111698107000 +2021,Table 1.4,BD,27,partnership_and_s_corp_income,All,5000000.0,10000000.0,True,False,False,51294 +2021,Table 1.4,BE,28,partnership_and_s_corp_income,All,10000000.0,inf,False,False,False,269603756000 +2021,Table 1.4,BD,28,partnership_and_s_corp_income,All,10000000.0,inf,True,False,False,38208 +2021,Table 1.4,BG,10,partnership_and_s_corp_losses,All,-inf,0.0,False,False,False,71077341000 +2021,Table 1.4,BG,30,partnership_and_s_corp_losses,All,-inf,0.0,False,True,False,3223563000 +2021,Table 1.4,BF,10,partnership_and_s_corp_losses,All,-inf,0.0,True,False,False,338591 +2021,Table 1.4,BF,30,partnership_and_s_corp_losses,All,-inf,0.0,True,True,False,2276 +2021,Table 1.4,BG,9,partnership_and_s_corp_losses,All,-inf,inf,False,False,True,260841147000 +2021,Table 1.4,BG,29,partnership_and_s_corp_losses,All,-inf,inf,False,True,False,173545899000 +2021,Table 1.4,BF,9,partnership_and_s_corp_losses,All,-inf,inf,True,False,True,3444331 +2021,Table 1.4,BF,29,partnership_and_s_corp_losses,All,-inf,inf,True,True,False,2608073 +2021,Table 1.4,BG,11,partnership_and_s_corp_losses,All,1.0,5000.0,False,False,False,1075829000 +2021,Table 1.4,BG,31,partnership_and_s_corp_losses,All,1.0,5000.0,False,True,False,16171000 +2021,Table 1.4,BF,11,partnership_and_s_corp_losses,All,1.0,5000.0,True,False,False,42742 +2021,Table 1.4,BF,31,partnership_and_s_corp_losses,All,1.0,5000.0,True,True,False,997 +2021,Table 1.4,BG,12,partnership_and_s_corp_losses,All,5000.0,10000.0,False,False,False,1526643000 2021,Table 1.4,BG,32,partnership_and_s_corp_losses,All,5000.0,10000.0,False,True,False,103813000 -2021,Table 1.4,BF,12,partnership_and_s_corp_losses,All,5000.0,10000.0,True,False,False,25878 +2021,Table 1.4,BF,12,partnership_and_s_corp_losses,All,5000.0,10000.0,True,False,False,54467 2021,Table 1.4,BF,32,partnership_and_s_corp_losses,All,5000.0,10000.0,True,True,False,1842 -2021,Table 1.4,BG,13,partnership_and_s_corp_losses,All,10000.0,15000.0,False,False,False,398235000 +2021,Table 1.4,BG,13,partnership_and_s_corp_losses,All,10000.0,15000.0,False,False,False,1287709000 2021,Table 1.4,BG,33,partnership_and_s_corp_losses,All,10000.0,15000.0,False,True,False,22740000 -2021,Table 1.4,BF,13,partnership_and_s_corp_losses,All,10000.0,15000.0,True,False,False,27240 +2021,Table 1.4,BF,13,partnership_and_s_corp_losses,All,10000.0,15000.0,True,False,False,50193 2021,Table 1.4,BF,33,partnership_and_s_corp_losses,All,10000.0,15000.0,True,True,False,5012 -2021,Table 1.4,BG,14,partnership_and_s_corp_losses,All,15000.0,20000.0,False,False,False,454719000 -2021,Table 1.4,BG,34,partnership_and_s_corp_losses,All,15000.0,20000.0,False,True,False,5799000 -2021,Table 1.4,BF,14,partnership_and_s_corp_losses,All,15000.0,20000.0,True,False,False,33786 -2021,Table 1.4,BF,34,partnership_and_s_corp_losses,All,15000.0,20000.0,True,True,False,3162 -2021,Table 1.4,BG,15,partnership_and_s_corp_losses,All,20000.0,25000.0,False,False,False,447752000 -2021,Table 1.4,BG,35,partnership_and_s_corp_losses,All,20000.0,25000.0,False,True,False,42878000 -2021,Table 1.4,BF,15,partnership_and_s_corp_losses,All,20000.0,25000.0,True,False,False,31513 -2021,Table 1.4,BF,35,partnership_and_s_corp_losses,All,20000.0,25000.0,True,True,False,8052 -2021,Table 1.4,BG,16,partnership_and_s_corp_losses,All,25000.0,30000.0,False,False,False,476041000 -2021,Table 1.4,BG,36,partnership_and_s_corp_losses,All,25000.0,30000.0,False,True,False,109977000 -2021,Table 1.4,BF,16,partnership_and_s_corp_losses,All,25000.0,30000.0,True,False,False,35076 -2021,Table 1.4,BF,36,partnership_and_s_corp_losses,All,25000.0,30000.0,True,True,False,14990 -2021,Table 1.4,BG,17,partnership_and_s_corp_losses,All,30000.0,40000.0,False,False,False,1060851000 -2021,Table 1.4,BG,37,partnership_and_s_corp_losses,All,30000.0,40000.0,False,True,False,319438000 -2021,Table 1.4,BF,17,partnership_and_s_corp_losses,All,30000.0,40000.0,True,False,False,56150 -2021,Table 1.4,BF,37,partnership_and_s_corp_losses,All,30000.0,40000.0,True,True,False,31968 -2021,Table 1.4,BG,18,partnership_and_s_corp_losses,All,40000.0,50000.0,False,False,False,935985000 -2021,Table 1.4,BG,38,partnership_and_s_corp_losses,All,40000.0,50000.0,False,True,False,347815000 -2021,Table 1.4,BF,18,partnership_and_s_corp_losses,All,40000.0,50000.0,True,False,False,70656 -2021,Table 1.4,BF,38,partnership_and_s_corp_losses,All,40000.0,50000.0,True,True,False,51893 -2021,Table 1.4,BG,19,partnership_and_s_corp_losses,All,50000.0,75000.0,False,False,False,2714271000 -2021,Table 1.4,BG,39,partnership_and_s_corp_losses,All,50000.0,75000.0,False,True,False,1533833000 -2021,Table 1.4,BF,19,partnership_and_s_corp_losses,All,50000.0,75000.0,True,False,False,155127 -2021,Table 1.4,BF,39,partnership_and_s_corp_losses,All,50000.0,75000.0,True,True,False,129747 -2021,Table 1.4,BG,20,partnership_and_s_corp_losses,All,75000.0,100000.0,False,False,False,2618448000 -2021,Table 1.4,BG,40,partnership_and_s_corp_losses,All,75000.0,100000.0,False,True,False,1583184000 -2021,Table 1.4,BF,20,partnership_and_s_corp_losses,All,75000.0,100000.0,True,False,False,164162 -2021,Table 1.4,BF,40,partnership_and_s_corp_losses,All,75000.0,100000.0,True,True,False,146314 -2021,Table 1.4,BG,21,partnership_and_s_corp_losses,All,100000.0,200000.0,False,False,False,8777366000 -2021,Table 1.4,BG,41,partnership_and_s_corp_losses,All,100000.0,200000.0,False,True,False,6908693000 -2021,Table 1.4,BF,21,partnership_and_s_corp_losses,All,100000.0,200000.0,True,False,False,464313 -2021,Table 1.4,BF,41,partnership_and_s_corp_losses,All,100000.0,200000.0,True,True,False,443453 -2021,Table 1.4,BG,22,partnership_and_s_corp_losses,All,200000.0,500000.0,False,False,False,14325853000 -2021,Table 1.4,BG,42,partnership_and_s_corp_losses,All,200000.0,500000.0,False,True,False,13673330000 -2021,Table 1.4,BF,22,partnership_and_s_corp_losses,All,200000.0,500000.0,True,False,False,410608 -2021,Table 1.4,BF,42,partnership_and_s_corp_losses,All,200000.0,500000.0,True,True,False,408865 -2021,Table 1.4,BG,23,partnership_and_s_corp_losses,All,500000.0,1000000.0,False,False,False,11738936000 -2021,Table 1.4,BG,43,partnership_and_s_corp_losses,All,500000.0,1000000.0,False,True,False,11625216000 -2021,Table 1.4,BF,23,partnership_and_s_corp_losses,All,500000.0,1000000.0,True,False,False,175073 -2021,Table 1.4,BF,43,partnership_and_s_corp_losses,All,500000.0,1000000.0,True,True,False,174965 -2021,Table 1.4,BG,24,partnership_and_s_corp_losses,All,1000000.0,1500000.0,False,False,False,6368462000 -2021,Table 1.4,BF,24,partnership_and_s_corp_losses,All,1000000.0,1500000.0,True,False,False,57269 -2021,Table 1.4,BG,44,partnership_and_s_corp_losses,All,1000000.0,inf,False,True,False,81546739000 -2021,Table 1.4,BF,44,partnership_and_s_corp_losses,All,1000000.0,inf,True,True,False,166529 -2021,Table 1.4,BG,25,partnership_and_s_corp_losses,All,1500000.0,2000000.0,False,False,False,4021272000 -2021,Table 1.4,BF,25,partnership_and_s_corp_losses,All,1500000.0,2000000.0,True,False,False,27788 -2021,Table 1.4,BG,26,partnership_and_s_corp_losses,All,2000000.0,5000000.0,False,False,False,13693841000 -2021,Table 1.4,BF,26,partnership_and_s_corp_losses,All,2000000.0,5000000.0,True,False,False,50191 -2021,Table 1.4,BG,27,partnership_and_s_corp_losses,All,5000000.0,10000000.0,False,False,False,9249576000 -2021,Table 1.4,BF,27,partnership_and_s_corp_losses,All,5000000.0,10000000.0,True,False,False,16687 -2021,Table 1.4,BG,28,partnership_and_s_corp_losses,All,10000000.0,inf,False,False,False,48549844000 -2021,Table 1.4,BF,28,partnership_and_s_corp_losses,All,10000000.0,inf,True,False,False,14688 +2021,Table 1.4,BG,14,partnership_and_s_corp_losses,All,15000.0,20000.0,False,False,False,1612436000 +2021,Table 1.4,BG,34,partnership_and_s_corp_losses,All,15000.0,20000.0,False,True,False,130978000 +2021,Table 1.4,BF,14,partnership_and_s_corp_losses,All,15000.0,20000.0,True,False,False,70310 +2021,Table 1.4,BF,34,partnership_and_s_corp_losses,All,15000.0,20000.0,True,True,False,13258 +2021,Table 1.4,BG,15,partnership_and_s_corp_losses,All,20000.0,25000.0,False,False,False,1138604000 +2021,Table 1.4,BG,35,partnership_and_s_corp_losses,All,20000.0,25000.0,False,True,False,129429000 +2021,Table 1.4,BF,15,partnership_and_s_corp_losses,All,20000.0,25000.0,True,False,False,60158 +2021,Table 1.4,BF,35,partnership_and_s_corp_losses,All,20000.0,25000.0,True,True,False,15352 +2021,Table 1.4,BG,16,partnership_and_s_corp_losses,All,25000.0,30000.0,False,False,False,1372282000 +2021,Table 1.4,BG,36,partnership_and_s_corp_losses,All,25000.0,30000.0,False,True,False,303730000 +2021,Table 1.4,BF,16,partnership_and_s_corp_losses,All,25000.0,30000.0,True,False,False,63849 +2021,Table 1.4,BF,36,partnership_and_s_corp_losses,All,25000.0,30000.0,True,True,False,29479 +2021,Table 1.4,BG,17,partnership_and_s_corp_losses,All,30000.0,40000.0,False,False,False,2643384000 +2021,Table 1.4,BG,37,partnership_and_s_corp_losses,All,30000.0,40000.0,False,True,False,909052000 +2021,Table 1.4,BF,17,partnership_and_s_corp_losses,All,30000.0,40000.0,True,False,False,123148 +2021,Table 1.4,BF,37,partnership_and_s_corp_losses,All,30000.0,40000.0,True,True,False,65040 +2021,Table 1.4,BG,18,partnership_and_s_corp_losses,All,40000.0,50000.0,False,False,False,1998743000 +2021,Table 1.4,BG,38,partnership_and_s_corp_losses,All,40000.0,50000.0,False,True,False,883215000 +2021,Table 1.4,BF,18,partnership_and_s_corp_losses,All,40000.0,50000.0,True,False,False,118522 +2021,Table 1.4,BF,38,partnership_and_s_corp_losses,All,40000.0,50000.0,True,True,False,87879 +2021,Table 1.4,BG,19,partnership_and_s_corp_losses,All,50000.0,75000.0,False,False,False,7096586000 +2021,Table 1.4,BG,39,partnership_and_s_corp_losses,All,50000.0,75000.0,False,True,False,4201805000 +2021,Table 1.4,BF,19,partnership_and_s_corp_losses,All,50000.0,75000.0,True,False,False,315753 +2021,Table 1.4,BF,39,partnership_and_s_corp_losses,All,50000.0,75000.0,True,True,False,252874 +2021,Table 1.4,BG,20,partnership_and_s_corp_losses,All,75000.0,100000.0,False,False,False,6088365000 +2021,Table 1.4,BG,40,partnership_and_s_corp_losses,All,75000.0,100000.0,False,True,False,4302660000 +2021,Table 1.4,BF,20,partnership_and_s_corp_losses,All,75000.0,100000.0,True,False,False,289414 +2021,Table 1.4,BF,40,partnership_and_s_corp_losses,All,75000.0,100000.0,True,True,False,259444 +2021,Table 1.4,BG,21,partnership_and_s_corp_losses,All,100000.0,200000.0,False,False,False,18194486000 +2021,Table 1.4,BG,41,partnership_and_s_corp_losses,All,100000.0,200000.0,False,True,False,14992747000 +2021,Table 1.4,BF,21,partnership_and_s_corp_losses,All,100000.0,200000.0,True,False,False,818577 +2021,Table 1.4,BF,41,partnership_and_s_corp_losses,All,100000.0,200000.0,True,True,False,778961 +2021,Table 1.4,BG,22,partnership_and_s_corp_losses,All,200000.0,500000.0,False,False,False,24100077000 +2021,Table 1.4,BG,42,partnership_and_s_corp_losses,All,200000.0,500000.0,False,True,False,23236311000 +2021,Table 1.4,BF,22,partnership_and_s_corp_losses,All,200000.0,500000.0,True,False,False,633067 +2021,Table 1.4,BF,42,partnership_and_s_corp_losses,All,200000.0,500000.0,True,True,False,630463 +2021,Table 1.4,BG,23,partnership_and_s_corp_losses,All,500000.0,1000000.0,False,False,False,17044916000 +2021,Table 1.4,BG,43,partnership_and_s_corp_losses,All,500000.0,1000000.0,False,True,False,16911002000 +2021,Table 1.4,BF,23,partnership_and_s_corp_losses,All,500000.0,1000000.0,True,False,False,243058 +2021,Table 1.4,BF,43,partnership_and_s_corp_losses,All,500000.0,1000000.0,True,True,False,242875 +2021,Table 1.4,BG,24,partnership_and_s_corp_losses,All,1000000.0,1500000.0,False,False,False,8770210000 +2021,Table 1.4,BF,24,partnership_and_s_corp_losses,All,1000000.0,1500000.0,True,False,False,76758 +2021,Table 1.4,BG,44,partnership_and_s_corp_losses,All,1000000.0,inf,False,True,False,104178687000 +2021,Table 1.4,BF,44,partnership_and_s_corp_losses,All,1000000.0,inf,True,True,False,222320 +2021,Table 1.4,BG,25,partnership_and_s_corp_losses,All,1500000.0,2000000.0,False,False,False,5542594000 +2021,Table 1.4,BF,25,partnership_and_s_corp_losses,All,1500000.0,2000000.0,True,False,False,37017 +2021,Table 1.4,BG,26,partnership_and_s_corp_losses,All,2000000.0,5000000.0,False,False,False,18083170000 +2021,Table 1.4,BF,26,partnership_and_s_corp_losses,All,2000000.0,5000000.0,True,False,False,66284 +2021,Table 1.4,BG,27,partnership_and_s_corp_losses,All,5000000.0,10000000.0,False,False,False,11883221000 +2021,Table 1.4,BF,27,partnership_and_s_corp_losses,All,5000000.0,10000000.0,True,False,False,22375 +2021,Table 1.4,BG,28,partnership_and_s_corp_losses,All,10000000.0,inf,False,False,False,60304551000 +2021,Table 1.4,BF,28,partnership_and_s_corp_losses,All,10000000.0,inf,True,False,False,20051 2021,Table 1.4,DY,10,qualified_business_income_deduction,All,-inf,0.0,False,False,False,0 2021,Table 1.4,DY,30,qualified_business_income_deduction,All,-inf,0.0,False,True,False,0 2021,Table 1.4,DX,10,qualified_business_income_deduction,All,-inf,0.0,True,False,False,0 diff --git a/tax_microdata_benchmarking/utils/soi_targets.py b/tax_microdata_benchmarking/utils/soi_targets.py index 43dab20d..55a557a1 100644 --- a/tax_microdata_benchmarking/utils/soi_targets.py +++ b/tax_microdata_benchmarking/utils/soi_targets.py @@ -139,11 +139,10 @@ def clean_vname(vname): "unempcomp": "unemployment compensation", "wages": "employment income", "partnerloss": "partnership and S corp losses", - "partnerpinc": "partnership and S corp income", - "qbid": "qualified business income deduction", - "scorpinc": "S-corporation net income", - "scorploss": "S-corporation net losses", "partnerinc": "partnership and S corp income", + "qbid": "qualified business income deduction", + "scorpinc": "S corporation net income", + "scorploss": "S corporation net losses", "idcontributions": "charitable contributions deductions", "idgst": "itemized general sales tax deduction", "idintpaid": "interest paid deductions", @@ -163,6 +162,8 @@ def clean_vname(vname): def clean_soi_file(soi): + soi.vname = soi.vname.replace("nret_partnerpinc", "nret_partnerinc") # Typo + soi["Count"] = soi.vname.apply(lambda x: "nret" in x) soi["Taxable only"] = soi.datatype == "taxable" soi.ptarget[~soi.Count] *= 1e3 @@ -242,16 +243,8 @@ def clean_soi_file(soi): soi = soi.groupby(unique_columns).first().reset_index() - soi[soi.Year == 2021][ - soi.Variable == "partnership_and_s_corp_income" - ] += soi[soi.Year == 2021][soi.Variable == "s_corporation_net_income"] - - soi[soi.Year == 2021][ - soi.Variable == "partnership_and_s_corp_losses" - ] += soi[soi.Year == 2021][soi.Variable == "s_corporation_net_losses"] - - soi = soi[soi.Variable != "s_corporation_net_income"] - soi = soi[soi.Variable != "s_corporation_net_losses"] + soi.Value[(soi.Year == 2021) & (soi.Variable == "partnership_and_s_corp_income")] += soi.Value[(soi.Year == 2021) & (soi.Variable == "s_corporation_net_income")].values + soi.Value[(soi.Year == 2021) & (soi.Variable == "partnership_and_s_corp_losses")] += soi.Value[(soi.Year == 2021) & (soi.Variable == "s_corporation_net_losses")].values return soi[columns] From 96a2937e97f2eccff67ca197c9227e9cfef8029d Mon Sep 17 00:00:00 2001 From: Nikhil Woodruff Date: Tue, 9 Jul 2024 11:58:35 +0100 Subject: [PATCH 3/6] Add test --- tax_microdata_benchmarking/utils/soi_targets.py | 16 +++++++++++++--- tests/test_flat_file.py | 9 +++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/tax_microdata_benchmarking/utils/soi_targets.py b/tax_microdata_benchmarking/utils/soi_targets.py index 55a557a1..2776d729 100644 --- a/tax_microdata_benchmarking/utils/soi_targets.py +++ b/tax_microdata_benchmarking/utils/soi_targets.py @@ -162,7 +162,9 @@ def clean_vname(vname): def clean_soi_file(soi): - soi.vname = soi.vname.replace("nret_partnerpinc", "nret_partnerinc") # Typo + soi.vname = soi.vname.replace( + "nret_partnerpinc", "nret_partnerinc" + ) # Typo soi["Count"] = soi.vname.apply(lambda x: "nret" in x) soi["Taxable only"] = soi.datatype == "taxable" @@ -243,8 +245,16 @@ def clean_soi_file(soi): soi = soi.groupby(unique_columns).first().reset_index() - soi.Value[(soi.Year == 2021) & (soi.Variable == "partnership_and_s_corp_income")] += soi.Value[(soi.Year == 2021) & (soi.Variable == "s_corporation_net_income")].values - soi.Value[(soi.Year == 2021) & (soi.Variable == "partnership_and_s_corp_losses")] += soi.Value[(soi.Year == 2021) & (soi.Variable == "s_corporation_net_losses")].values + soi.Value[ + (soi.Year == 2021) & (soi.Variable == "partnership_and_s_corp_income") + ] += soi.Value[ + (soi.Year == 2021) & (soi.Variable == "s_corporation_net_income") + ].values + soi.Value[ + (soi.Year == 2021) & (soi.Variable == "partnership_and_s_corp_losses") + ] += soi.Value[ + (soi.Year == 2021) & (soi.Variable == "s_corporation_net_losses") + ].values return soi[columns] diff --git a/tests/test_flat_file.py b/tests/test_flat_file.py index 2b6c5f7a..32880dd3 100644 --- a/tests/test_flat_file.py +++ b/tests/test_flat_file.py @@ -169,3 +169,12 @@ def test_qbided_close_to_soi(flat_file): assert ( abs((flat_file.s006 * flat_file.qbided).sum() / 1e9 / 205.8 - 1) < 0.25 ), "QBIDED not within 25 percent of 205.8bn" + + +@pytest.mark.parametrize( + "flat_file", datasets_to_test, ids=dataset_names_to_test +) +def test_partnership_s_corp_income_close_to_soi(flat_file): + assert ( + abs((flat_file.s006 * flat_file.e26270).sum() / 1e9 / 975 - 1) < 0.1 + ), "Partnership/S-Corp income not within 10 percent of 975bn" From 16bbedf999014f881069690085a560b93fdccad8 Mon Sep 17 00:00:00 2001 From: "martin.holmer@gmail.com" Date: Wed, 10 Jul 2024 08:03:01 -0400 Subject: [PATCH 4/6] Change SCALE from 0.33 to 0.20 --- tax_microdata_benchmarking/imputation_assumptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tax_microdata_benchmarking/imputation_assumptions.py b/tax_microdata_benchmarking/imputation_assumptions.py index 58b573ae..2264a008 100644 --- a/tax_microdata_benchmarking/imputation_assumptions.py +++ b/tax_microdata_benchmarking/imputation_assumptions.py @@ -6,4 +6,4 @@ IMPUTATION_BETA_RNG_SEED = 37465 # random number seed used for Beta variates -W2_WAGES_SCALE = 0.33 # parameter used to impute pass-through W-2 wages +W2_WAGES_SCALE = 0.20 # parameter used to impute pass-through W-2 wages From f9f2c10d3d6c4801daba3c680693dc6174850f30 Mon Sep 17 00:00:00 2001 From: "martin.holmer@gmail.com" Date: Wed, 10 Jul 2024 08:03:58 -0400 Subject: [PATCH 5/6] Skip e02000 and e26270 variable total tests --- tax_microdata_benchmarking/create_taxcalc_input_variables.py | 2 +- tests/tc_variable_totals.yaml | 4 ++-- tests/test_flat_file.py | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tax_microdata_benchmarking/create_taxcalc_input_variables.py b/tax_microdata_benchmarking/create_taxcalc_input_variables.py index 3dda6ca8..2afca0e0 100644 --- a/tax_microdata_benchmarking/create_taxcalc_input_variables.py +++ b/tax_microdata_benchmarking/create_taxcalc_input_variables.py @@ -33,6 +33,7 @@ def create_variable_file(write_file=True): print(f"Writing PUF+CPS file... [{fname}]") vdf.to_csv(fname, index=False) # streamline dataframe so that it includes only input variables + print("Removing output variables from PUF+CPS DataFrame...") rec = tc.Records( data=vdf, start_year=TAXYEAR, @@ -53,6 +54,5 @@ def create_variable_file(write_file=True): print(f"Writing PUF+CPS file... [{fname}]") vdf.to_csv(fname, index=False, float_format="%.2f") - if __name__ == "__main__": create_variable_file() diff --git a/tests/tc_variable_totals.yaml b/tests/tc_variable_totals.yaml index 736ad34a..d27b7bc9 100644 --- a/tests/tc_variable_totals.yaml +++ b/tests/tc_variable_totals.yaml @@ -33,7 +33,7 @@ e01200: -60216853854.91481 e01400: 552468020849.5068 e01500: 1641191913466.6348 e01700: 1000550811057.0841 -e02000: 927149787725.4258 +e02000: 0.0 # 27149787725.4258 e02100: -6522807775.893997 e02100p: -6333314477.3977 e02100s: -189493275.0666 @@ -67,7 +67,7 @@ e20100: 64814165943.684494 e20400: 213136239172.01752 e24515: 46065816558.2304 e24518: 12744333564.099298 -e26270: 733636357457.6952 +e26270: 0.0 # 733636357457.6952 e27200: 11361348668.954098 e32800: 29847384812.3065 e58990: 4155217553.2594 diff --git a/tests/test_flat_file.py b/tests/test_flat_file.py index 32880dd3..4dc9f430 100644 --- a/tests/test_flat_file.py +++ b/tests/test_flat_file.py @@ -82,6 +82,7 @@ ] +@pytest.mark.vartotals @pytest.mark.parametrize("variable", variables_to_test, ids=lambda x: x) @pytest.mark.parametrize( "flat_file", datasets_to_test, ids=dataset_names_to_test From 02357990e9e4ac6cb9798c3c2a6d5df51868d198 Mon Sep 17 00:00:00 2001 From: "martin.holmer@gmail.com" Date: Wed, 10 Jul 2024 08:05:53 -0400 Subject: [PATCH 6/6] black format change --- tax_microdata_benchmarking/create_taxcalc_input_variables.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tax_microdata_benchmarking/create_taxcalc_input_variables.py b/tax_microdata_benchmarking/create_taxcalc_input_variables.py index 2afca0e0..b8e5c1a3 100644 --- a/tax_microdata_benchmarking/create_taxcalc_input_variables.py +++ b/tax_microdata_benchmarking/create_taxcalc_input_variables.py @@ -54,5 +54,6 @@ def create_variable_file(write_file=True): print(f"Writing PUF+CPS file... [{fname}]") vdf.to_csv(fname, index=False, float_format="%.2f") + if __name__ == "__main__": create_variable_file()