Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
73 lines (58 sloc) 3.25 KB

How to Use Tax-Brain

The Tax-Brain package is centered around the TaxBrain object. Any analysis using Tax-Brain starts by importing and creating a TaxBrain instance.

from taxbrain import TaxBrain

tb = TaxBrain(2019, 2029, use_cps=True, reform="reform.json",
              assump="assumptions.json", behavior={"sub": 0.25})

TaxBrain takes the following arguments on initialization:

  1. start_year: First year in the analysis.
  2. end_year: Last year in the analysis.
  3. microdata*: Either a path to a micro-data CSV file or a Pandas DataFrame containing micro-data suitable for use in Tax-Calculator
  4. use_cps*: Boolean indicator for whether to use the CPS micro-data file included in Tax-Calculator. If this is true, do not give a value for the microdata argument.
  5. reform*: Individual income tax policy reform. Can either be a string pointing to a JSON file, the contents of a JSON file, or a dictionary.
  6. behavior*: Individual behavioral assumptions used by the Behavioral-Responses package.
  7. assump*: Economic assumptions. Can either be a string pointing to a JSON file, the contents of a JSON file, or a dictionary.
  8. verbose*: Boolean indicator for whether or not to print progress updates as the models run. Default value is False.

* indicates optional argument

Tax-Brain will analyze these inputs to determine which models to run and for what years. To start the models, the users can simply use the run method:

This will create two Tax-Calculator instances - one for current law (base) and another for the user specified policy (reform).

run() also takes an optional argument, varlist, to indicate which variables in the micro-data the user would like saved. Pandas DataFrames containing micro-data from the reform and base calculators are stored in the reform_data and base_data, respectively, attributes of the TaxBrain instance (both attributes are dictionaries).

The dictionaries are structured so that each year in the analysis is a key paired to the DataFrame for that particular year:

# Access the DataFrame containing data from the reform caclulator for the year 2019
# Access the DataFrame containing data from the base calculator for the year 2020

This gives the user the option of performing a more detailed analysis of the data or producing custom tables and graphs. There are also multiple built in methods for producing tables:

  • weighted_totals(var): Produces a table with the weighted sum of the specified variables (var) for each year in the analysis under the baseline policy, reform policy, and the difference between the two.
  • `distribution_table(year, groupby, income_measure, calc): Produces a table showing the distribution of a number of variables across the income spectrum.
  • differences_table(year, groupby, tax_to_diff): Produces a table showing the change in a number of variables across the income distribution.

As more models are added, Tax-Brain's usage will change to adjust. While we will try and maintain backwards compatibility, that obviously cannot always happen. This document will be updated as Tax-Brain evolves.

You can’t perform that action at this time.