Functions to Get Micro-data#

get_micro_data.py modules

ogusa.get_micro_data#


ogusa.get_micro_data.cap_inc_mtr(calc1)[source]#

This function computes the marginal tax rate on capital income, which is calculated as a weighted average of the marginal tax rates on different sources of capital income.

Parameters:

calc1 (Tax-Calculator Calculator object) – TC calculator

Returns:

array with marginal tax rates

for each observation in the TC Records object

Return type:

mtr_combined_capinc (Numpy array)

ogusa.get_micro_data.get_calculator(calculator_start_year, iit_baseline=None, iit_reform=None, data=None, gfactors=None, weights=None, records_start_year=2011)[source]#

This function creates the tax calculator object with the policy specified in reform and the data specified with the data kwarg.

Parameters:
  • calculator_start_year (int) – first year of budget window

  • reform (dictionary) – IIT policy reform parameters, None if baseline

  • data (DataFrame or str) – DataFrame or path to datafile for Records object

  • gfactors (Tax-Calculator GrowthFactors object) – growth factors to use to extrapolate data over budget window

  • weights (DataFrame) – weights for Records object

  • records_start_year (int) – the start year for the data and weights dfs (default is set to the PUF start year as defined in the Tax-Calculator project)

Returns:

Calculator object with

current_year equal to calculator_start_year

Return type:

calc1 (Tax-Calculator Calculator object)

ogusa.get_micro_data.get_data(baseline=False, start_year=2021, iit_baseline=None, iit_reform={}, data=None, gfactors=None, weights=None, records_start_year=2014, path='/home/runner/work/OG-USA/OG-USA/ogusa', client=None, num_workers=1)[source]#

This function creates dataframes of micro data with marginal tax rates and information to compute effective tax rates from the Tax-Calculator output. The resulting dictionary of dataframes is returned and saved to disk in a pickle file.

Parameters:
  • baseline (boolean) – True if baseline tax policy

  • calculator_start_year (int) – first year of budget window

  • iit_baseline (dictionary) – IIT policy parameters for baseline

  • iit_reform (dictionary) – IIT policy reform parameters, None if baseline

  • data (str or Pandas DataFrame) – path or DataFrame with data for Tax-Calculator model

  • gfactors (str or Pandas DataFrame) – path or DataFrame with growth factors for Tax-Calculator model

  • weights (str or Pandas DataFrame) – path or DataFrame with weights for Tax-Calculator model

  • records_start_year (int) – year micro data begins

  • path (str) – path to save microdata files to

  • client (Dask Client object) – client for Dask multiprocessing

  • num_workers (int) – number of workers to use for Dask multiprocessing

Returns:

dict of Pandas Dataframe, one for each

year from start_year to the maximum year Tax-Calculator can analyze

taxcalc_version (str): version of Tax-Calculator used

Return type:

micro_data_dict (dict)

ogusa.get_micro_data.is_paramtools_format(reform)[source]#

Check first item in reform to determine if it is using the ParamTools adjustment or the Tax-Calculator reform format. If first item is a dict, then it is likely be a Tax-Calculator reform: {

param: {2020: 1000}

} Otherwise, it is likely to be a ParamTools format.

Parameters:

reform (dict or str) – JSON string or dictionary of reform parameters

Returns:

True if reform is likely to be in PT format.

Return type:

format (bool)

ogusa.get_micro_data.taxcalc_advance(start_year, iit_baseline, iit_reform, data, gfactors, weights, records_start_year, year)[source]#

This function advances the year used in Tax-Calculator, compute taxes and rates, and save the results to a dictionary.

Parameters:
  • start_year (int) – first year of budget window

  • iit_baseline (dict) – IIT policy parameters for baseline

  • iit_reform (dict) – IIT policy reform parameters for reform

  • data (str or Pandas DataFrame) – path or DataFrame with data for Tax-Calculator model

  • gfactors (str or Pandas DataFrame) – path or DataFrame with growth factors for Tax-Calculator model

  • weights (str or Pandas DataFrame) – path or DataFrame with weights for Tax-Calculator model

  • records_start_year (int) – year micro data begins

  • year (int) – year to advance to in Tax-Calculator

Returns:

a dictionary of microdata with marginal tax

rates and other information computed in TC

Return type:

tax_dict (dict)

ogusa.get_micro_data.update_policy(policy_obj, reform, **kwargs)[source]#

Convenience method that updates the Policy object with the reform dict using the appropriate method, given the reform format.

Parameters:
  • policy_obj (Policy object) – Tax-Calculator Policy object

  • reform (dict or str) – JSON string or dictionary of reform parameters

  • kwargs (dict) – keyword arguments to pass to the adjust method

Returns:

None (updates policy object)