How to Utilize the Outputs of Functions
When users execute some functions, the output is Vector{<:PosteriorSample}. The examples of Vector{<:PosteriorSample} are
Vector{Parameter}: output ofposterior_samplerVector{ReducedForm}: output ofreducedformVector{LatentSpace}: output oflatentspaceVector{YieldCurve}: output offitted_YieldCurveVector{TermPremium}: output ofterm_premiumVector{Forecast}: outputs ofconditional_forecastsandscenario_analysis
Each entry of the above vectors is a posterior sample and takes the form of a struct, which is one of the following: Parameter, ReducedForm, LatentSpace, YieldCurve, TermPremium, Forecast. The above six struct have their unique fields. See the API section to see what fields each struct contains. Section Notations explains the specific meanings of the fields.
Extract Posterior Samples of the fields
Vector{<:PosteriorSample} contains posterior samples of the fields of the corresponding struct. You can call posterior samples of a specific field by using getindex. For example, if we want to get posterior samples of phi in Parameter, run
samples_phi = saved_params[:phi]for saved_params::Vector{Parameter}. Then, samples_phi is a vector, and samples_phi[i] is the i-th posterior sample of phi. Note that samples_phi[i] is a matrix in this case. (Julialang allows Vector to have Array elements.)
Descriptive Statistics of the Posterior Distributions
We extend mean, var, std, median, and quantile from Statistics.jl to Vector{<:PosteriorSample}. These five functions can be conveniently used to calculate descriptive statistics of the posterior distribution, such as the posterior mean or posterior variance. For example, the posterior mean of phi can be calculated by
mean_phi = mean(saved_params)[:phi]mean_phi[i,j] is the posterior mean of the entry in the i-th row and j-th column of phi. Outputs of all functions(mean, var, std, median, and quantile) have the same shapes as their corresponding parameters. quantile needs the second input. For example, in the case of
q_phi = quantile(saved_params, 0.4)[:phi]40% of posterior samples of phi[i,j] are less than q_phi[i,j].
To get posterior samples or posterior descriptive statistics of a specific object, we need to know which struct contains the object as a field. Section Notations organizes which structs contain the object.