Parameter Plotting Functions

Parameter Plotting Functions

parameter_plots.py modules

ogcore.parameter_plots

ogcore.parameter_plots.gen_3Dscatters_hist(df, s, t, output_dir)[source]

Create 3-D scatterplots and corresponding 3D histogram of ETR, MTRx, and MTRy as functions of labor income and capital income with truncated data in the income dimension

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

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

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

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

Returns

None

ogcore.parameter_plots.plot_2D_taxfunc(year, start_year, tax_param_list, age=None, tax_func_type=['DEP'], rate_type='etr', over_labinc=True, other_inc_val=1000, max_inc_amt=1000000, data_list=None, labels=['1st Functions'], title=None, path=None)[source]

This function plots OG-Core tax functions in two dimensions. The tax rates are plotted over capital or labor income, as entered by the user.

Parameters
  • year (int) – year of policy tax functions represent

  • start_year (int) – first year tax functions estimated for in tax_param_list elements

  • tax_param_list (list) – list of arrays containing tax function parameters

  • age (int) – age for tax functions to plot, use None if tax function parameters were not age specific

  • tax_func_type (list) – list of strings in [“DEP”, “DEP_totalinc”, “GS”, “linear”] and specifies functional form of tax functions in tax_param_list

  • rate_type (str) – string that is in [“etr”, “mtrx”, “mtry”] and determines the type of tax rate that is plotted

  • over_labinc (bool) – indicates that x-axis of the plot is over labor income, if False then plot is over capital income

  • other_inc_val (scalar) – dollar value at which to hold constant the amount of income that is not represented on the x-axis

  • max_inc_amt (scalar) – largest income amount to represent on the x-axis of the plot

  • data_list (list) – list of DataFrames with data to scatter plot with tax functions, needs to be of format output from ogcore.get_micro_data.get_data

  • labels (list) – list of labels for tax function parameters

  • title (str) – title for the plot

  • path (str) – path to which to save plot, if None then figure returned

Returns

plot of tax functions

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_ability_profiles(p, include_title=False, path=None)[source]

Create a plot of earnings ability profiles.

Parameters
  • p (OG-Core Specifications class) – parameters object

  • path (string) – path to save figure to

Returns

plot of earnings ability profiles

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_chi_n(p, include_title=False, path=None)[source]

Create a plot of showing the values of the chi_n parameters.

Parameters
  • p (OG-Core Specifications class) – parameters object

  • path (string) – path to save figure to

Returns

plot of chi_n parameters

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_elliptical_u(p, plot_MU=True, include_title=False, path=None)[source]

Create a plot of showing the fit of the elliptical utility function.

Parameters
  • p (OG-Core Specifications class) – parameters object

  • plot_MU (boolean) – whether plot marginal utility or utility in levels

  • path (string) – path to save figure to

Returns

plot of elliptical vs CFE utility

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_fert_rates(fert_func, age_midp, totpers, min_yr, max_yr, fert_data, fert_rates, output_dir=None)[source]

Plot fertility rates from the data along with smoothed function to use for model fertility rates.

Parameters
  • fert_func (Scipy interpolation object) – interpolated fertility rates

  • age_midp (NumPy array) – midpoint of age for each age group in data

  • totpers (int) – total number of agent life periods (E+S), >= 3

  • min_yr (int) – age in years at which agents are born, >= 0

  • max_yr (int) – age in years at which agents die with certainty, >= 4

  • fert_data (NumPy array) – fertility rates by age group from data

  • fert_rates (NumPy array) – fitted fertility rates for each of totpers

  • output_dir (str) – path to save figure to, if None then figure is returned

Returns

plot of fertility rates

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_imm_fixed(age_per_EpS, imm_rates_orig, imm_rates_adj, E, S, output_dir=None)[source]

Plot the immigration rates implied by the data on population, mortality, and fertility versus the adjusted immigration rates needed to achieve a stationary distribution of the population in a reasonable number of model periods.

Parameters
  • age_per_EpS (array_like) – list of ages over which to plot population distribution

  • imm_rates_orig (Numpy array) – immigration rates by age

  • imm_rates_adj (Numpy array) – adjusted immigration rates by age

  • E (int) – age at which household becomes economically active

  • S (int) – number of years which household is economically active

  • output_dir (str) – path to save figure to, if None then figure is returned

Returns

plot of immigration rates found

from residuals and the adjusted rates to hit SS sooner

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_imm_rates(p, year=2021, include_title=False, path=None)[source]

Create a plot of immigration rates from OG-Core parameterization.

Parameters
  • p (OG-Core Specifications class) – parameters object

  • year (integer) – year of mortality ratese to plot

  • include_title (bool) – whether to include a title in the plot

  • path (string) – path to save figure to

Returns

plot of immigration rates

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_income_data(ages, abil_midp, abil_pcts, emat, output_dir=None, filesuffix='')[source]

This function graphs ability matrix in 3D, 2D, log, and nolog

Parameters
  • ages (Numpy array) –

  • abil_midp (Numpy array) – midpoints of income percentile bins in each ability group

  • abil_pcts (Numpy array) – percent of population in each lifetime income group, length J

  • emat (Numpy array) – effective labor units by age and lifetime income group, size SxJ

  • filesuffix (str) – suffix to be added to plot files

Returns

None

ogcore.parameter_plots.plot_mort_rates(p, include_title=False, path=None)[source]

Create a plot of mortality rates from OG-Core parameterization.

Parameters
  • p (OG-Core Specifications class) – parameters object

  • include_title (bool) – whether to include a title in the plot

  • path (string) – path to save figure to

Returns

plot of immigration rates

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_mort_rates_data(totpers, min_yr, max_yr, age_year_all, mort_rates_all, infmort_rate, mort_rates, output_dir=None)[source]

Plots mortality rates from the model and data.

Parameters
  • totpers (int) – total number of agent life periods (E+S), >= 3

  • min_yr (int) – age in years at which agents are born, >= 0

  • max_yr (int) – age in years at which agents die with certainty, >= 4

  • age_year_all (array_like) – ages in mortality rate data

  • mort_rates_all (array_like) – mortality rates by age from data, average across males and females

  • infmort_rate (scalar) – infant mortality rate

  • mort_rates (array_like) – fitted mortality rates for each of totpers

  • output_dir (str) – path to save figure to, if None then figure is returned

Returns

plot of mortality rates

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_omega_fixed(age_per_EpS, omega_SS_orig, omega_SSfx, E, S, output_dir=None)[source]

Plot the steady-state population distribution implied by the data on fertility and mortality rates versus the the steady-state population distribution after adjusting immigration rates so that the stationary distribution is achieved a reasonable number of model periods.

Parameters
  • age_per_EpS (array_like) – list of ages over which to plot population distribution

  • omega_SS_orig (Numpy array) – population distribution in SS without adjustment to immigration rates

  • omega_SSfx (Numpy array) – population distribution in SS after adjustment to immigration rates

  • E (int) – age at which household becomes economically active

  • S (int) – number of years which household is economically active

  • output_dir (str) – path to save figure to, if None then figure is returned

Returns

plot of SS population distribution

before and after adjustment to immigration rates

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_pop_growth(p, start_year=2021, num_years_to_plot=150, include_title=False, path=None)[source]

Create a plot of population growth rates by year.

Parameters
  • p (OG-Core Specifications class) – parameters object

  • start_year (integer) – year to begin plotting

  • num_years_to_plot (integer) – number of years to plot

  • include_title (bool) – whether to include a title in the plot

  • path (string) – path to save figure to

Returns

plot of immigration rates

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.plot_population_path(age_per_EpS, pop_2013_pct, omega_path_lev, omega_SSfx, curr_year, E, S, output_dir=None)[source]

Plot the distribution of the population over age for various years.

Parameters
  • age_per_EpS (array_like) – list of ages over which to plot population distribution

  • pop_2013_pct (array_like) – population distribution in 2013

  • omega_path_lev (Numpy array) – number of households by age over the transition path

  • omega_SSfx (Numpy array) – number of households by age in the SS

  • curr_year (int) – current year in the model

  • E (int) – age at which household becomes economically active

  • S (int) – number of years which household is economically active

  • output_dir (str) – path to save figure to, if None then figure is returned

Returns

plot of population distribution

at points along the time path

Return type

fig (Matplotlib plot object)

ogcore.parameter_plots.txfunc_graph(s, t, df, X, Y, txrates, rate_type, tax_func_type, get_tax_rates, params_to_plot, output_dir)[source]

This function creates a 3D plot of the fitted tax function against the data.

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

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

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

  • X (Pandas DataSeries) – labor income

  • Y (Pandas DataSeries) – capital income

  • Y – tax rates from the data

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

  • tax_func_type (str) – functional form of tax functions

  • get_tax_rates (function) – function to generate tax rates given parameters

  • params_to_plot (Numpy Array) – tax function parameters

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

Returns

None

ogcore.parameter_plots.txfunc_sse_plot(age_vec, sse_mat, start_year, varstr, output_dir, round)[source]

Plot sum of squared errors of tax functions over age for each year of budget window.

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

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

  • start_year (int) – first year of budget window

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

  • output_dir (str) – path to save graph to

  • round (int) – which round of sweeping for outliers (0, 1, or 2)

Returns

None