-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add examination alt_ctc_taxexp.py script
- Loading branch information
1 parent
60fa0f1
commit 1681c00
Showing
7 changed files
with
96 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
tax_microdata_benchmarking/examination/taxcalculator/alt_ctc_taxexp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ dwks43 | |
e00650 | ||
p23250 | ||
taxbc | ||
ctc_total | ||
iitax | ||
s006 |
3 changes: 2 additions & 1 deletion
3
tax_microdata_benchmarking/examination/taxcalculator/ctc.dvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
ctc_total | ||
ctc_refundable | ||
iitax | ||
s006 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tax_microdata_benchmarking/examination/taxcalculator/puf-26.res-expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters