Skip to content

Commit

Permalink
Add examination alt_ctc_taxexp.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Jul 6, 2024
1 parent 60fa0f1 commit 1681c00
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tax_microdata_benchmarking/examination/results3.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ merge of PR 2764 on 2024-07-04).
| ---: | ---: | :--- |
| 2512.3 | 2849.4 | CBO |
| 2371.4 | 2999.4 | Tax-Calculator + phase 3 dataset |
| 2247.8 | 2742.1 | Tax-Calculator + taxdata dataset |
| 2247.9 | 2742.2 | Tax-Calculator + taxdata dataset |

<br>

Expand All @@ -52,7 +52,7 @@ merge of PR 2764 on 2024-07-04).
| 122.1 | 57.6 | JCT |
| 108.6 | 55.7 | TSY |
| 73.5 | 26.7 | Tax-Calculator + phase 3 dataset |
| 126.2 | 43.1 | Tax-Calculator + taxdata dataset |
| 126.3 | 43.1 | Tax-Calculator + taxdata dataset |

<br>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""
Tabulate alternative CTC tax-expenditure estimate.
"""

import os
import sys
import argparse
import pandas as pd


def main():
"""
High-level script logic.
"""
# parse command-line arguments
usage_str = "python alt_ctc_taxexp.py INPUT YEAR [--help]"
parser = argparse.ArgumentParser(
prog="", usage=usage_str, description=__doc__
)
parser.add_argument(
"INPUT",
help="Name of CSV-formatted file containing the input dataset",
nargs="?",
default="",
)
parser.add_argument(
"YEAR",
help="Tax policy calendar year of tax-expenditure results",
type=int,
nargs="?",
default=0,
)
args = parser.parse_args()

# check command-line argument values
args_ok = True
if args.INPUT.endswith(".csv"):
sys.stderr.write(f"ERROR: {args.INPUT} ends with .csv\n")
args_ok = False
if args.YEAR not in [23, 26]:
sys.stderr.write(f"ERROR: YEAR {args.YEAR} is neither 23 nor 26\n")
args_ok = False
if not args_ok:
sys.stderr.write(f"USAGE: {usage_str}\n")
return 1

# construct baseline and tax-expenditure reform dump output file names
generic = f"{args.INPUT}-{args.YEAR}-#-xxx-#.csv"
bas_fname = generic.replace("xxx", "clp")
ref_fname = generic.replace("xxx", "ctc")
args_ok = True
if not os.path.isfile(bas_fname):
sys.stderr.write(f"ERROR: {bas_fname} file does not exist\n")
args_ok = False
if not os.path.isfile(ref_fname):
sys.stderr.write(f"ERROR: {ref_fname} file does not exist\n")
args_ok = False
if not args_ok:
sys.stderr.write(f"USAGE: {usage_str}\n")
return 1

# read base and reform .csv dump output files
bdf = pd.read_csv(bas_fname)
rdf = pd.read_csv(ref_fname)

# standard tax-expenditure tabulation using iitax
btax = (bdf.s006 * bdf.iitax).sum() * 1e-9
rtax = (rdf.s006 * rdf.iitax).sum() * 1e-9
std_te = rtax - btax
print(f"STD tax-expenditure($B)= {std_te:.3f}")

# alternative tax-expenditure tabulation using ctc_total
bctc = (bdf.s006 * bdf.ctc_total).sum() * 1e-9
rctc = (rdf.s006 * rdf.ctc_total).sum() * 1e-9
alt_te = bctc - rctc
print(f"ALT tax-expenditure($B)= {alt_te:.3f}")

# return no-error exit code
return 0


if __name__ == "__main__":
sys.exit(main())
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ dwks43
e00650
p23250
taxbc
ctc_total
iitax
s006
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ctc_total
ctc_refundable
iitax
s006
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Weighted Tax Reform Totals by Baseline Expanded-Income Decile
Returns ExpInc IncTax PayTax LSTax AllTax
A 208.42 18638.0 2247.8 1489.3 0.0 3737.1
A 208.42 18638.0 2247.9 1489.3 0.0 3737.2

==> puf-23-#-cgqd-#-tab.text <==
A 208.42 18638.0 217.7 0.0 0.0 217.7
Expand All @@ -9,7 +9,7 @@ Weighted Tax Reform Totals by Baseline Expanded-Income Decile
A 208.42 18638.0 0.0 0.0 0.0 0.0

==> puf-23-#-ctc-#-tab.text <==
A 208.42 18638.0 126.2 0.0 0.0 126.2
A 208.42 18638.0 126.3 0.0 0.0 126.3

==> puf-23-#-eitc-#-tab.text <==
A 208.42 18638.0 73.5 0.0 0.0 73.5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Weighted Tax Reform Totals by Baseline Expanded-Income Decile
Returns ExpInc IncTax PayTax LSTax AllTax
A 216.75 21231.4 2742.1 1711.0 0.0 4453.1
A 216.75 21231.4 2742.2 1711.0 0.0 4453.1

==> puf-26-#-cgqd-#-tab.text <==
A 216.75 21231.4 223.6 0.0 0.0 223.6
Expand Down
3 changes: 3 additions & 0 deletions tax_microdata_benchmarking/examination/taxcalculator/runs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ echo CLP

echo CTC
./execute.sh $1.csv 20$2 ctc
if [[ -v QUIT ]]; then
exit 1
fi

echo EITC
./execute.sh $1.csv 20$2 eitc
Expand Down

0 comments on commit 1681c00

Please sign in to comment.