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
path (str) – output directory for saving plot files
- Returns:
None
- ogcore.parameter_plots.plot_2D_taxfunc(year, start_year, tax_param_list, age=None, E=21, 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, p2=None, t=None, log_scale=False, include_title=False, path=None)[source]#
Create a plot of earnings ability profiles.
- Parameters:
p (OG-Core Specifications class) – parameters object
t (int) – model period for year, if None, then plot ability matrix for SS
log_scale (bool) – whether to plot in log points
include_title (bool) – whether to include a title in the plot
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_list, labels=[''], years_to_plot=[2025], include_title=False, path=None)[source]#
Create a plot of showing the values of the chi_n parameters.
- Parameters:
p_list (list) – parameters objects
labels (list) – labels for legend
years_to_plot (list) – list of years to plot
include_title (boolean) – whether to include a title in the plot
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_rates_list, labels=[''], start_year=2025, years_to_plot=[2025], include_title=False, source='United Nations, World Population Prospects', path=None)[source]#
Plot fertility rates from the data
- Parameters:
fert_rates_list (list) – list of Numpy arrays of fertility rates for each model period and age
labels (list) – list of labels for the legend
start_year (int) – first year of data
years_to_plot (list) – list of years to plot
include_title (bool) – whether to include a title in the plot
source (str) – data source for fertility rates
path (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_g_n(p_list, label_list=[''], include_title=False, path=None)[source]#
Create a plot of population growth rates from OG-Core parameterization.
- Parameters:
p_list (list) – list of OG-Core Specifications objects
label_list (list) – list of labels for the legend
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_imm_fixed(age_per_EpS, imm_rates_orig, imm_rates_adj, E, S, path=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
path (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(imm_rates, start_year=2025, years_to_plot=[2025], include_title=False, source='United Nations, World Population Prospects', path=None)[source]#
Plot fertility rates from the data
- Parameters:
imm_rates (NumPy array) – immigration rates for each of totpers
start_year (int) – first year of data
years_to_plot (list) – list of years to plot
source (str) – data source for fertility rates
path (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_income_data(ages, abil_midp, abil_pcts, emat, t=None, path=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 TxSxJ
t (int) – model period for year, if None, then plot SS values
filesuffix (str) – suffix to be added to plot files
- Returns:
None
- ogcore.parameter_plots.plot_mort_rates(p_list, labels=[''], years=[2025], survival_rates=False, include_title=False, path=None)[source]#
Create a plot of mortality rates from OG-Core parameterization.
- Parameters:
p_list (list) – list of parameters objects
labels (list) – list of labels for the legend
survival_rates (bool) – whether to plot survival rates instead of mortality rates
include_title (bool) – whether to include a title in the plot
path (string) – path to save figure to
- Returns:
plot of mortality rates
- Return type:
fig (Matplotlib plot object)
- ogcore.parameter_plots.plot_mort_rates_data(mort_rates, start_year=2025, years_to_plot=[2025], source='United Nations, World Population Prospects', path=None)[source]#
Plots mortality rates from the data.
- Parameters:
mort_rates (array_like) – mortality rates for each of totpers
start_year (int) – first year of data
years_to_plot (list) – list of years to plot
source (str) – data source for fertility rates
path (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, path=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
path (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=2025, 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, omega_path_lev, omega_SSfx, start_year, year1, year2, S, path=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
initial_pop_pct (array_like) – initial year population distribution
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
start_year (int) – first year of data (so can get index of year1 and year2)
year1 (int) – first year of data to plot
year2 (int) – second year of data to plot
S (int) – number of years which household is economically active
path (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, 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
params_to_plot (array_like or function) – tax function parameters or nonparametric function
path (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 BW x S
start_year (int) – first year of budget window
varstr (str) – name of tax function being evaluated
path (str) – path to save graph to
round (int) – which round of sweeping for outliers (0, 1, or 2)
- Returns:
None