Tax-Brain Class Object#

taxbrain

taxbrain.taxbrain#

class taxbrain.taxbrain.TaxBrain(start_year: int, end_year: int = 2034, microdata: str | dict | None = None, use_cps: bool = False, reform: str | dict | None = None, behavior: dict | None = None, assump=None, base_policy: str | dict | None = None, corp_revenue: dict | list | array | None = None, corp_incidence_assumptions: dict | None = None, verbose=False, stacked=False)[source]#
differences_table(year: int, groupby: str, tax_to_diff: str, pop_quantiles: bool = False) DataFrame[source]#

Method to create a differences table

Parameters:
  • year (int) – which year the difference table should be from

  • groupby (str) – determines how the rows in the table are sorted options: ‘weighted_deciles’, ‘standard_income_bins’, ‘soi_agi_bin’

  • tax_to_diff (str) – which tax to take the difference of options: ‘iitax’, ‘payrolltax’, ‘combined’

  • pop_quantiles (bool) – whether weighted_deciles contain an equal number of tax units (False) or people (True)

Returns:

table – differences table

Return type:

Pandas DataFrame

distribution_table(year: int, groupby: str, income_measure: str, calc: str, pop_quantiles: bool = False) DataFrame[source]#

Method to create a distribution table

Parameters:
  • year (int) – which year the distribution table data should be from

  • groupby (str) – determines how the rows in the table are sorted options: ‘weighted_deciles’, ‘standard_income_bins’, ‘soi_agi_bin’

  • income_measure (str) – determines which variable is used to sort the rows in the table options: ‘expanded_income’ or ‘expanded_income_baseline’

  • calc (which calculator to use: base or reform) – which calculator to use, can take either ‘REFORM’ or ‘BASE’

  • calc

  • pop_quantiles (bool) – whether or not weighted_deciles contain equal number of tax units (False) or people (True)

Returns:

table – distribution table

Return type:

Pandas DataFrame

multi_var_table(varlist: list, calc: str, include_total: bool = False) DataFrame[source]#

Create a Pandas DataFrame with multiple variables from the specified data source

Parameters:
  • varlist (list) – list of variables to include in the table

  • calc (str) – specify reform or base calculator data, can take either ‘REFORM’ or ‘BASE’

  • include_total (bool) – If true the returned DataFrame will include a “total” column

Returns:

df – A Pandas DataFrame containing the weighted sum of each variable passed in the varlist argument for each year in the analysis.

Return type:

Pandas DataFrame

run(varlist: list = ['c04600', 'c07100', 'iitax', 'ubi', 'c09600', 'combined', 's006', 'c62100', 'surtax', 'c05800', 'taxbc', 'XTOT', 'c00100', 'c04470', 'benefit_value_total', 'aftertax_income', 'benefit_cost_total', 'refund', 'othertaxes', 'payrolltax', 'standard', 'c04800', 'expanded_income'], client=None, num_workers=1)[source]#

Run the calculators. TaxBrain will determine whether to do a static or partial equilibrium run based on the user’s inputs when initializing the TaxBrain object.

Parameters:

varlist (list) – variables from the microdata to be stored in each year

Return type:

None

weighted_totals(var: str, include_total: bool = False) DataFrame[source]#

Create a pandas DataFrame that shows the weighted sum or a specified variable under the baseline policy, reform policy, and the difference between the two.

Parameters:
  • var (str) – Variable name for variable you want the weighted total of.

  • include_total (bool) – If true the returned DataFrame will include a “total” columns

Returns:

A Pandas DataFrame with rows for the baseline total, reform total, and the difference between the two.

Return type:

Pandas DataFrame