
Obtain samples from the posterior distribution of reported quantities
Source:R/get-posterior.R
get_posterior.RdStored MCMC draws contain the fitted model parameters. Derived report
quantities such as B0, spawning_biomass_y, or M_a are
evaluated for each draw by this function.
Arguments
- object
An optimized RTMB objective with a callable
report()function.- posterior
A posterior object supported by
SparseNUTS::extract_samples(), including the object returned byas_tmbfitfor ansbt_fitwith stored MCMC draws.- pars
A character vector. The names of derived quantities to extract from the model report (e.g., "B0", "M_a"). Default is "B0".
- iters
An
integer. The number of posterior iterations to extract. IfNULL(default), all available iterations are extracted.- option
Integer parallelization mode: 1 evaluates sequentially and 2 uses a PSOCK cluster across chains.
- type
Character output format.
"df"returns a long data frame,"array"returns one array per report quantity, and any other value returns the underlying nested chain list.
Value
Depends on type argument:
- type = "df"
A
data.framewith columns: parameter (character), index (integer), chain (integer), iteration (integer), and value (numeric).- type = "array"
A named
listof arrays, one per parameter, with dimensions \[chain, iteration, parameter dimensions\].- type = other
A nested
liststructure: chains > parameters > iterations.