How to Utilize the Outputs of Functions
When you execute some functions, the output is Vector{<:PosteriorSample}. Examples of Vector{<:PosteriorSample} include
Vector{Parameter}: output ofposterior_samplerVector{ReducedForm}: output ofreducedformVector{LatentSpace}: output oflatentspaceVector{YieldCurve}: output offitted_yieldcurveVector{TermPremium}: output ofterm_premiumVector{Forecast}: outputs ofconditional_forecastandconditional_expectation
Each entry in the vectors above is a posterior sample and takes the form of a struct: Parameter, ReducedForm, LatentSpace, YieldCurve, TermPremium, or Forecast. The above six structs have unique fields. See the API section for the fields each struct contains. The Notations section 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 access posterior samples of a specific field by using getindex. For example, if you 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. (Julia allows vectors to have array elements.)
Descriptive Statistics of the Posterior Distributions
The package extends mean, var, std, median, and quantile from Statistics.jl to Vector{<:PosteriorSample}. These five functions can be 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. The outputs of all functions (mean, var, std, median, and quantile) have the same shapes as their corresponding parameters. quantile needs a 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, you need to know which struct contains the object as a field. The Notations section organizes which structs contain the object.