In Model, we provide the equations that describe the model that this package solves. All the functions and types used in the package are documented in the Library: public and internal functionality.
Settings
This document was generated with Documenter.jl version 0.27.25 on Monday 25 September 2023. Using Julia version 1.7.3.
In Model, we provide the equations that describe the model that this package solves. All the functions and types used in the package are documented in the Library: public and internal functionality.
Settings
This document was generated with Documenter.jl version 0.27.25 on Tuesday 19 December 2023. Using Julia version 1.7.3.
Returns argument that maximises value of function f over the interval [a,b] and value of function f at the maximising point using the Golden search method.
Loads decile data from a predefined CSV file and returns it as a MicroData structure.
Arguments
filename::String: The path to the CSV file containing the decile data. Example: nlsydata/afqt_decile_1.csv.
group::String: (optional) The group to which the data should be restricted. Valid values are "Black", "White", or an empty string (default).
Returns
A MicroData instance containing the loaded decile data.
Notes
The CSV file is expected to have the following columns: "wage", "hours", "employed", and "weights" (or columns that contain these strings as substrings).
If group is specified, the data will be restricted to the specified group ("Black" or "White") based on the values in the "black" column.
Examples
data = loaddeciledata("nlsydata/afqt_decile_1.csv") # Load all decile data
-data = loaddeciledata("nlsydata/afqt_decile_1.csv", "black") # Load decile data for the black group only
Computes aggregate statistics from the MicroData instance d using the specified statistical function f. The function computes aggregate statistics for wage, hours, employment, total income (all individuals), and income (employed individuals).
Arguments
f: A function that computes the desired aggregate statistic.
d::MicroData: A MicroData instance containing agent/individual-level data.
Note
The function handles missing values by replacing them with zeros for the total income variable.
Returns MicroData instance after simulating economy based on the realisations of the staying-at-home shock (iκs) and the policy function (n) for one level of ability to accumulate human capital.
Arguments
ia::Int64: Index of the ability to accumulate human capital.
iκs::Matrix{Int64}: Matrix of the indices of realisations of the staying-at-home shock.
n::Vector{Matrix{Float64}}: Policy function for hours worked.
p::ModelParameters: Instance of ModelParameters containing relevant parameter values.
empsample::Bool = true: Flag indicating whether to use treshold to allocate employment indicator.
Simulates hours worked and human capital based on realisations of the staying-at-home shock (iκs) and the policy function (n) for one level of ability to accumulate human capital.
Arguments
ia::Int64: Index of the ability to accumulate human capital.
iκs::Matrix{Int64}: Matrix of the indices of realisations of the staying-at-home shock.
n::Vector{Matrix{Float64}}: Policy function for hours worked.
p::ModelParameters: Instance of ModelParameters containing model relevant parameter values.
A composite type that represents individual-level data on wages, hours worked, employment status, and individual population weights. Each row corresponds to an agent/individual, and each column represents a period.
Returns argument that maximises value of function f over the interval [a,b] and value of function f at the maximising point using the Golden search method.
Loads decile data from a predefined CSV file and returns it as a MicroData structure.
Arguments
filename::String: The path to the CSV file containing the decile data. Example: nlsydata/afqt_decile_1.csv.
group::String: (optional) The group to which the data should be restricted. Valid values are "Black", "White", or an empty string (default).
Returns
A MicroData instance containing the loaded decile data.
Notes
The CSV file is expected to have the following columns: "wage", "hours", "employed", and "weights" (or columns that contain these strings as substrings).
If group is specified, the data will be restricted to the specified group ("Black" or "White") based on the values in the "black" column.
Examples
data = loaddeciledata("nlsydata/afqt_decile_1.csv") # Load all decile data
+data = loaddeciledata("nlsydata/afqt_decile_1.csv", "black") # Load decile data for the black group only
Computes aggregate statistics from the MicroData instance d using the specified statistical function f. The function computes aggregate statistics for wage, hours, employment, total income (all individuals), and income (employed individuals).
Arguments
f: A function that computes the desired aggregate statistic.
d::MicroData: A MicroData instance containing agent/individual-level data.
Note
The function handles missing values by replacing them with zeros for the total income variable.
Returns MicroData instance after simulating economy based on the realisations of the staying-at-home shock (iκs) and the policy function (n) for one level of ability to accumulate human capital.
Arguments
ia::Int64: Index of the ability to accumulate human capital.
iκs::Matrix{Int64}: Matrix of the indices of realisations of the staying-at-home shock.
n::Vector{Matrix{Float64}}: Policy function for hours worked.
p::ModelParameters: Instance of ModelParameters containing relevant parameter values.
empsample::Bool = true: Flag indicating whether to use treshold to allocate employment indicator.
Simulates hours worked and human capital based on realisations of the staying-at-home shock (iκs) and the policy function (n) for one level of ability to accumulate human capital.
Arguments
ia::Int64: Index of the ability to accumulate human capital.
iκs::Matrix{Int64}: Matrix of the indices of realisations of the staying-at-home shock.
n::Vector{Matrix{Float64}}: Policy function for hours worked.
p::ModelParameters: Instance of ModelParameters containing model relevant parameter values.
A composite type that represents individual-level data on wages, hours worked, employment status, and individual population weights. Each row corresponds to an agent/individual, and each column represents a period.
Concatenates multiple MicroData instances based on groupings provided in grps.
Arguments
grps::Vector: Vector of groupings, where each element is a single index (an Int64) or a range of indices (UnitRange{Int64}). The indices correspond to the positions of MicroData instances in the input vector v.
v::Vector{MicroData}: Vector of MicroData instances to be concatenated.
Notes
The length of the grps vector must be less than or equal to the length of the v vector.
Each element in grps specifies a grouping of MicroData instances to be concatenated together.
The output vector z has the same length as the grps vector.
Computes the weighted mean of each field in the vector of AgeData instances v for specific groupings defined by the indices in grps, using the popshare field from the ModelParameters object p as weights.
Arguments
grps::Vector: Vector of groupings, where each element is a single index (an Int64) or a range of indices (UnitRange{Int64}). The indices correspond to the positions of MicroData instances in the input vector v.
v::Vector{AgeData}: A vector of AgeData instances.
p::ModelParameters: A ModelParameters instance.
Notes
The length of the grps vector must be less than or equal to the length of the v vector.
Each element in grps specifies a grouping of MicroData instances to be concatenated together.
The output vector z has the same length as the grps vector.
Generates a LaTeX table with counterfactual results based on the provided gaps dictionary.
Arguments
gaps::Dict{String, AggregateData}: Dictionary containing counterfactual results for different scenarios. The keys are scenario names, and the values are AggregateData instances representing the gaps.
Note
This function generates a LaTeX document and saves it as a file named "counterfactuals.tex" in the "tables" directory. The LaTeX document contains a table displaying the counterfactual results.
Creates a new instance of ModelParameters by modifying the fields specified in np... while copying the remaining fields from the generateparameters(group) function.
Arguments
group::String: The name of the predefined group. It can be either "Black" or "White".
np...: Keyword arguments representing the fields of ModelParameters with their desired values. Example: ψ = 1.0, γ = 2.0.
Note
The function assumes that the specified keyword arguments correspond to the fields of ModelParameters.
Concatenates multiple MicroData instances based on groupings provided in grps.
Arguments
grps::Vector: Vector of groupings, where each element is a single index (an Int64) or a range of indices (UnitRange{Int64}). The indices correspond to the positions of MicroData instances in the input vector v.
v::Vector{MicroData}: Vector of MicroData instances to be concatenated.
Notes
The length of the grps vector must be less than or equal to the length of the v vector.
Each element in grps specifies a grouping of MicroData instances to be concatenated together.
The output vector z has the same length as the grps vector.
Computes the weighted mean of each field in the vector of AgeData instances v for specific groupings defined by the indices in grps, using the popshare field from the ModelParameters object p as weights.
Arguments
grps::Vector: Vector of groupings, where each element is a single index (an Int64) or a range of indices (UnitRange{Int64}). The indices correspond to the positions of MicroData instances in the input vector v.
v::Vector{AgeData}: A vector of AgeData instances.
p::ModelParameters: A ModelParameters instance.
Notes
The length of the grps vector must be less than or equal to the length of the v vector.
Each element in grps specifies a grouping of MicroData instances to be concatenated together.
The output vector z has the same length as the grps vector.
Generates a LaTeX table with counterfactual results based on the provided gaps dictionary.
Arguments
gaps::Dict{String, AggregateData}: Dictionary containing counterfactual results for different scenarios. The keys are scenario names, and the values are AggregateData instances representing the gaps.
Note
This function generates a LaTeX document and saves it as a file named "counterfactuals.tex" in the "tables" directory. The LaTeX document contains a table displaying the counterfactual results.
Creates a new instance of ModelParameters by modifying the fields specified in np... while copying the remaining fields from the generateparameters(group) function.
Arguments
group::String: The name of the predefined group. It can be either "Black" or "White".
np...: Keyword arguments representing the fields of ModelParameters with their desired values. Example: ψ = 1.0, γ = 2.0.
Note
The function assumes that the specified keyword arguments correspond to the fields of ModelParameters.
Plots multiple subplots the model simulated data and real data with error bars representing the standard error.
Arguments
fn::Symbol: Field name to plot from AgeData instances.
m::Vector{AgeData}: Vector of AgeData structures of model simulated data.
d::Vector{AgeData}: Vector of AgeData structures of real data.
de::Union{Vector{AgeData}, Nothing} = nothing: Optional vector of AgeData instances representing standard errors for the data. If not provided (default), error bars will not be shown.
plt_ttl::String = "": Optional title for the overall plot.
lyt::Tuple{Int64, Int64} = (1, 5): Layout of subplots in rows and columns.
sz::Tuple{Int64, Int64} = (2000, 500): Size of the overall plot.
mrgn::Tuple{Int64, Symbol} = (50, :px): Margin size and unit for the overall plot.
ylms::Tuple{Float64, Float64} = (0, NaN): Y-axis limits for the overall plot.
haxis: Horizontal axis values for each subplot. Defaults to 1:length(d).
spttls::Vector{String} = fill("", length(d)): Titles for each subplot. Defaults to an empty string for each subplot.
mlbl::String = "Model": Label for the model predictions in the legend.
dlbl::String = "Data": Label for the data in the legend.
xlbl::String = "Age": Label for the x-axis.
flllph::Float64 = 0.1: Fill alpha value for the error bars. Defaults to 0.1.
zα::Float64 = 1.96: Z-value corresponding to the desired level of confidence for the error bars. Defaults to 1.96, representing the 95% confidence level.
Plots multiple subplots the model simulated data and real data with error bars representing the standard error.
Arguments
fn::Symbol: Field name to plot from AgeData instances.
m::Vector{AgeData}: Vector of AgeData structures of model simulated data.
d::Vector{AgeData}: Vector of AgeData structures of real data.
de::Union{Vector{AgeData}, Nothing} = nothing: Optional vector of AgeData instances representing standard errors for the data. If not provided (default), error bars will not be shown.
plt_ttl::String = "": Optional title for the overall plot.
lyt::Tuple{Int64, Int64} = (1, 5): Layout of subplots in rows and columns.
sz::Tuple{Int64, Int64} = (2000, 500): Size of the overall plot.
mrgn::Tuple{Int64, Symbol} = (50, :px): Margin size and unit for the overall plot.
ylms::Tuple{Float64, Float64} = (0, NaN): Y-axis limits for the overall plot.
haxis: Horizontal axis values for each subplot. Defaults to 1:length(d).
spttls::Vector{String} = fill("", length(d)): Titles for each subplot. Defaults to an empty string for each subplot.
mlbl::String = "Model": Label for the model predictions in the legend.
dlbl::String = "Data": Label for the data in the legend.
xlbl::String = "Age": Label for the x-axis.
flllph::Float64 = 0.1: Fill alpha value for the error bars. Defaults to 0.1.
zα::Float64 = 1.96: Z-value corresponding to the desired level of confidence for the error bars. Defaults to 1.96, representing the 95% confidence level.
Plots the model simulated data and real data with error bars representing the standard error.
Arguments
m::Vector{Float64}: Model simulated data.
d::Vector{Float64}: Real data.
de::Union{Vector{Float64}, Nothing} = nothing: Optional vector of standard errors for the data. If not provided (default), error bars will not be shown.
haxis: Horizontal axis values for the plot. Defaults to 1:length(d).
ttl::String = "": Optional title for the plot.
mlbl::String = "Model": Label for the model predictions in the legend.
dlbl::String = "Data": Label for the data in the legend.
xlbl::String = "Age": Label for the x-axis.
flllph::Float64 = 0.1: Fill alpha value for the error bars. Defaults to 0.1.
zα::Float64 = 1.96: Z-value corresponding to the desired level of confidence for the error bars. Defaults to 1.96, representing the 95% confidence level.
Solves the model using the labor supply decisions of the economy defined by pb while using the human capital parameters of pw.
Arguments
pb::ModelParameters: Instance of ModelParameters to compute labor supply decisions.
pw::ModelParameters: Instance of ModelParameters to use human capital parameters.
Note
This function returns a vector of simulated data for each level of ability/h₁. Each element in the vector represents the simulated data for one level and is of type MicroData.
Solves the model based on the parameters provided.
Arguments
p::ModelParameters: Instance of ModelParameters containing the model's parameter values.
empsample::Bool = true: (Optional) Flag indicating whether to use treshold to allocate employment indicator.
Note
This function returns a vector of simulated data for each level of ability/h₁. Each element in the vector represents the simulated data for one level and is of type MicroData.
Applies the statistical function f to each column of the wage, hours, and employed fields in the MicroData instance d weighted by the corresponding elements in the weights field, after skipping missing values.
Arguments
f: A statistical function to apply to each column of the fields in d.
d::MicroData: A MicroData object containing wage, hours, employed, and weights fields.
Composite type that contains a summary statistic for hourly wages among the employed, hours worked among the employed, employment rate, income among all, and income among the employed. For example, average wages.
Fields
wage::Float64: Average wage among the employed.
hours::Float64: Hours worked among the employed.
employment::Float64: Employment rate.
incomeall::Float64: Average income among all.
incomeemp::Float64: Average income among the employed.
This document was generated with Documenter.jl version 0.27.25 on Monday 25 September 2023. Using Julia version 1.7.3.
+ )
Plots the model simulated data and real data with error bars representing the standard error.
Arguments
m::Vector{Float64}: Model simulated data.
d::Vector{Float64}: Real data.
de::Union{Vector{Float64}, Nothing} = nothing: Optional vector of standard errors for the data. If not provided (default), error bars will not be shown.
haxis: Horizontal axis values for the plot. Defaults to 1:length(d).
ttl::String = "": Optional title for the plot.
mlbl::String = "Model": Label for the model predictions in the legend.
dlbl::String = "Data": Label for the data in the legend.
xlbl::String = "Age": Label for the x-axis.
flllph::Float64 = 0.1: Fill alpha value for the error bars. Defaults to 0.1.
zα::Float64 = 1.96: Z-value corresponding to the desired level of confidence for the error bars. Defaults to 1.96, representing the 95% confidence level.
Solves the model using the labor supply decisions of the economy defined by pb while using the human capital parameters of pw.
Arguments
pb::ModelParameters: Instance of ModelParameters to compute labor supply decisions.
pw::ModelParameters: Instance of ModelParameters to use human capital parameters.
Note
This function returns a vector of simulated data for each level of ability/h₁. Each element in the vector represents the simulated data for one level and is of type MicroData.
Solves the model based on the parameters provided.
Arguments
p::ModelParameters: Instance of ModelParameters containing the model's parameter values.
empsample::Bool = true: (Optional) Flag indicating whether to use treshold to allocate employment indicator.
Note
This function returns a vector of simulated data for each level of ability/h₁. Each element in the vector represents the simulated data for one level and is of type MicroData.
Applies the statistical function f to each column of the wage, hours, and employed fields in the MicroData instance d weighted by the corresponding elements in the weights field, after skipping missing values.
Arguments
f: A statistical function to apply to each column of the fields in d.
d::MicroData: A MicroData object containing wage, hours, employed, and weights fields.
Composite type that contains a summary statistic for hourly wages among the employed, hours worked among the employed, employment rate, income among all, and income among the employed. For example, average wages.
Fields
wage::Float64: Average wage among the employed.
hours::Float64: Hours worked among the employed.
employment::Float64: Employment rate.
incomeall::Float64: Average income among all.
incomeemp::Float64: Average income among the employed.
The function $h'$ defines how human capital evolves over the lifecycle. The parameter $\phi$ defines the curvature of human capital next period with respect to time spent working. We assume that human capital depreciates at a constant rate $\delta$. We model human capital accumulation as a learning-by-doing technology. The labor supply decision trades off less leisure today versus more income today and higher human capital in the future.
Settings
This document was generated with Documenter.jl version 0.27.25 on Monday 25 September 2023. Using Julia version 1.7.3.