Tax Function Estimation Functions

Tax Function Estimation Functions

txfunc.py modules

ogcore.txfunc

tau_{s,t} is the effective tax rate, marginal tax rate on labor income, or the marginal tax rate on capital income, for a given age (s) in a particular year (t). x is total labor income, and y is total capital income. ————————————————————————

ogcore.txfunc.find_outliers(sse_mat, age_vec, se_mult, start_year, varstr, graph=False)[source]

This function takes a matrix of sum of squared errors (SSE) from tax function estimations for each age (s) in each year of the budget window (t) and marks estimations that have outlier SSE.

Parameters
  • sse_mat (Numpy array) – SSE for each estimated tax function, size is SxBW

  • age_vec (numpy array) – vector of ages, length S

  • se_mult (scalar) – multiple of standard deviations before consider estimate an outlier

  • start_year (int) – first year of budget window

  • varstr (str) – name of tax function being evaluated

  • graph (bool) – whether to output graphs

Returns

indicators of whether tax function

is outlier, size is SxBW

Return type

sse_big_mat (Numpy array)

ogcore.txfunc.get_tax_rates(params, X, Y, wgts, tax_func_type, rate_type, analytical_mtrs=False, mtr_capital=False, for_estimation=True)[source]

Generates tax rates given income data and the parameters of the tax functions.

Parameters
  • params (tuple) – parameters of the tax function, varies by tax_func_type

  • X (array_like) – labor income data

  • Y (array_like) – capital income data

  • wgts (array_like) – weights for data observations

  • tax_func_type (str) – functional form of tax functions

  • rate_type (str) – type of tax rate: mtrx, mtry, etr

  • analytical_mtrs (bool) – whether to compute marginal tax rates from the total tax function (for DEP functions only)

  • mtr_capital (bool) – whether analytical mtr on capital income

  • for_estimation (bool) – whether the results are used in estimation, if True, then tax rates are computed as deviations from the mean

Returns

model tax rates for each observation

Return type

txrates (array_like)

ogcore.txfunc.replace_outliers(param_arr, sse_big_mat)[source]

This function replaces outlier estimated tax function parameters with linearly interpolated tax function tax function parameters

Parameters
  • param_arr (Numpy array) – estimated tax function parameters, size is SxBWx#tax params

  • sse_big_mat (Numpy array) – indicators of whether tax function is outlier, size is SxBW

Returns

estimated and interpolated tax

function parameters, size SxBWx#tax params

Return type

param_arr_adj (Numpy array)

ogcore.txfunc.tax_func_estimate(micro_data, BW, S, starting_age, ending_age, start_year=2021, baseline=True, analytical_mtrs=False, tax_func_type='DEP', age_specific=False, reform={}, data=None, desc_data=False, graph_data=False, graph_est=False, client=None, num_workers=1, tax_func_path=None)[source]

This function performs analysis on the source data from Tax- Calculator and estimates functions for the effective tax rate (ETR), marginal tax rate on labor income (MTRx), and marginal tax rate on capital income (MTRy).

Parameters
  • micro_data (dict) – Dictionary of DataFrames with micro data

  • BW (int) – number of years in the budget window (the period over which tax policy is assumed to vary)

  • S (int) – number of model periods a model agent is economically active for

  • starting_age (int) – minimum age to estimate tax functions for

  • ending_age (int) – maximum age to estimate tax functions for

  • start_yr (int) – first year of budget window

  • baseline (bool) – whether these are the baseline tax functions

  • analytical_mtrs (bool) – whether to use the analytical derivation of the marginal tax rates (and thus only need to estimate the effective tax rate functions)

  • tax_func_type (str) – functional form of tax functions

  • age_specific (bool) – whether to estimate age specific tax functions

  • reform (dict) – policy reform dictionary for Tax-Calculator

  • data (str or Pandas DataFrame) – path to or data to use in Tax-Calculator

  • client (Dask client object) – client

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

  • tax_func_path (str) – path to save pickle with estimated tax function parameters to

Returns

dictionary with tax function parameters

Return type

dict_param (dict)

ogcore.txfunc.tax_func_loop(t, data, start_year, s_min, s_max, age_specific, tax_func_type, analytical_mtrs, desc_data, graph_data, graph_est, output_dir, numparams)[source]

Estimates tax functions for a particular year. Looped over.

Parameters
  • t (int) – year of tax data to estimated tax functions for

  • data (Pandas DataFrame) – tax return data for year t

  • start_yr (int) – first year of budget window

  • s_min (int) – minimum age to estimate tax functions for

  • s_max (int) – maximum age to estimate tax functions for

  • age_specific (bool) – whether to estimate age specific tax functions

  • tax_func_type (str) – functional form of tax functions

  • analytical_mtrs (bool) – whether to use the analytical derivation of the marginal tax rates (and thus only need to estimate the effective tax rate functions)

  • desc_data (bool) – whether to print descriptive statistics

  • graph_data (bool) – whether to plot data

  • graph_est (bool) – whether to plot estimated coefficients

  • output_dir (str) – path to save output to

  • numparams (int) – number of parameters in tax functions

Returns

tax function estimation output:

  • TotPop_yr (int): total population derived from micro data

  • Pct_age (Numpy array): fraction of observations that are

    in each age bin

  • AvgInc (scalar): mean income in the data

  • AvgETR (scalar): mean effective tax rate in data

  • AvgMTRx (scalar): mean marginal tax rate on labor income

    in data

  • AvgMTRy (scalar): mean marginal tax rate on capital income

    in data

  • frac_tax_payroll (scalar): fraction of total tax revenue

    the comes from payroll taxes

  • etrparam_arr (Numpy array): parameters of the effective

    tax rate functions

  • etr_wsumsq_arr (Numpy array): weighted sum of squares from

    estimation of the effective tax rate functions

  • etr_obs_arr (Numpy array): weighted sum of squares from

    estimation of the effective tax rate functions

  • mtrxparam_arr (Numpy array): parameters of the marginal

    tax rate on labor income functions

  • mtrx_wsumsq_arr (Numpy array): weighted sum of squares

    from estimation of the marginal tax rate on labor income functions

  • mtrx_obs_arr (Numpy array): weighted sum of squares from

    estimation of the marginal tax rate on labor income functions

  • mtryparam_arr (Numpy array): parameters of the marginal

    tax rate on capital income functions

  • mtry_wsumsq_arr (Numpy array): weighted sum of squares

    from estimation of the marginal tax rate on capital income functions

  • mtry_obs_arr (Numpy array): weighted sum of squares from

    estimation of the marginal tax rate on capital income functions

Return type

(tuple)

ogcore.txfunc.txfunc_est(df, s, t, rate_type, tax_func_type, numparams, output_dir, graph)[source]

This function uses tax tax rate and income data for individuals of a particular age (s) and a particular year (t) to estimate the parameters of a Cobb-Douglas aggregation function of two ratios of polynomials in labor income and capital income, respectively.

Parameters
  • df (Pandas DataFrame) – 11 variables with N observations of tax rates

  • s (int) – age of individual, >= 21

  • t (int) – year of analysis, >= 2016

  • rate_type (str) – type of tax rate: mtrx, mtry, etr

  • tax_func_type (str) – functional form of tax functions

  • numparams (int) – number of parameters in the tax functions

  • output_dir (str) – output directory for saving plot files

  • graph (bool) – whether to plot the estimated functions compared to the data

Returns

tax function estimation output:

  • params (Numpy array): vector of estimated parameters

  • wsse (scalar): weighted sum of squared deviations from

    minimization

  • obs (int): number of observations in the data, > 600

Return type

(tuple)

ogcore.txfunc.wsumsq(params, *args)[source]

This function generates the weighted sum of squared deviations of predicted values of tax rates (ETR, MTRx, or MTRy) from the tax rates from the data for the Cobb-Douglas functional form of the tax function.

Parameters
  • params (tuple) – tax function parameter values

  • args (tuple) – contains (fixed_tax_func_params, X, Y, txrates, wgts, tax_func_type, rate_type)

  • fixed_tax_func_params (tuple) – value of parameters of tax functions that are not estimated

  • X (array_like) – labor income data

  • Y (array_like) – capital income data

  • txrates (array_like) – tax rates data

  • wgts (array_like) – weights for data observations

  • tax_func_type (str) – functional form of tax functions

  • rate_type (str) – type of tax rate: mtrx, mtry, etr

Returns

weighted sum of squared deviations, >0

Return type

wssqdev (scalar)