示例#1
0
def cli_core(startyear, endyear, data, usecps, reform, behavior, assump,
             baseline, outdir, name, make_report, author):
    """
    Core logic for the CLI
    """
    tb = TaxBrain(start_year=startyear,
                  end_year=endyear,
                  microdata=data,
                  use_cps=usecps,
                  reform=reform,
                  behavior=behavior,
                  assump=assump,
                  base_policy=baseline,
                  verbose=True)
    tb.run()

    # create outputs
    dirname = name
    if not dirname:
        dirname = f"TaxBrain Analysis {datetime.today().date()}"
    outputpath = Path(outdir, dirname)
    outputpath.mkdir()
    # create output tables
    aggregate = tb.weighted_totals("combined")
    aggregate.to_csv(Path(outputpath, "aggregate_tax_liability.csv"))
    for year in range(startyear, endyear + 1):
        yeardir = Path(outputpath, str(year))
        yeardir.mkdir()
        make_tables(tb, year, yeardir)

    if make_report:
        report(tb, name=name, outdir=outputpath, author=author)
示例#2
0
文件: cli.py 项目: rickecon/Tax-Brain
def cli_core(startyear, endyear, data, usecps, reform, behavior, assump,
             baseline, outdir, name, make_report, author):
    """
    Core logic for the CLI

    Parameters
    ----------
    startyear: int
        year to start analysis
    endyear: int
        last year for analysis
    data: str or Pandas DataFrame
        path to or DataFrame with data for Tax-Calculator
    usecps: bool
        whether to use the CPS or (if False) the PUF-based file
    reform: dict
        parameter changes for reform run in Tax-Calculator
    behavior: dict
        behavioral assumptions for Behavioral-Responses
    assump: dict
        consumption assumptions
    base_policy: dict
        parameter changes (relative to current law baseline) for baseline
        policy
    verbose: bool
        indicator for printing of output

    Returns
    -------
    None
        reports saved to disk at path specified by outdir
    """
    tb = TaxBrain(start_year=startyear,
                  end_year=endyear,
                  microdata=data,
                  use_cps=usecps,
                  reform=reform,
                  behavior=behavior,
                  assump=assump,
                  base_policy=baseline,
                  verbose=True)
    tb.run()

    # create outputs
    dirname = name
    if not dirname:
        dirname = f"TaxBrain Analysis {datetime.today().date()}"
    outputpath = Path(outdir, dirname)
    outputpath.mkdir(exist_ok=True)
    # create output tables
    aggregate = tb.weighted_totals("combined")
    aggregate.to_csv(Path(outputpath, "aggregate_tax_liability.csv"))
    for year in range(startyear, endyear + 1):
        yeardir = Path(outputpath, str(year))
        yeardir.mkdir(exist_ok=True)
        make_tables(tb, year, yeardir)

    if make_report:
        report(tb, name=name, outdir=outputpath, author=author)
示例#3
0
from taxbrain import TaxBrain

reform_url = "https://raw.githubusercontent.com/PSLmodels/Tax-Calculator/master/taxcalc/reforms/Larson2019.json"

# run static analysis

tb_static = TaxBrain(2019, 2028, use_cps=True, reform=reform_url)
tb_static.run()
static_table = tb_static.weighted_totals("c00100")
print("Tax Liability by Year\n")
print("Static Results")
print(static_table)

# run dynamic analysis

tb_dynamic = TaxBrain(2019,
                      2028,
                      use_cps=True,
                      reform=reform_url,
                      behavior={"sub": 0.25})
tb_dynamic.run()
dynamic_table = tb_dynamic.weighted_totals("c00100")
print("Dynamic Results")
print(dynamic_table)

# produce a differences table

diff = tb_static.differences_table(2019, "weighted_deciles", "combined")
print("\nDifferences Table for 2019")
print(diff)