Whether to extract the warmup samples or not
(default). Warmup samples should never be used for inference, but may
be useful for diagnostics.
inc_lp
Whether to include a column for the log posterior density
(last column). For diagnostics it can be useful.
as.list
Whether to return the samples as a list (one element per
chain). This could then be converted to a CODA mcmc object.
Value
If as.list is FALSE, an invisible data.frame containing samples
(rows) of each parameter (columns). If multiple chains exist they will
be rbinded together, maintaining order within each chain. If as.list
is TRUE, samples are returned as a list of matrices.
Details
This function is loosely based on the rstan function
extract. Merging samples across chains should only be used for
inference after appropriate diagnostic checks. Do not calculate
diagnostics like Rhat or effective sample size after using this
function, instead, use monitor. Likewise, warmup
samples are not valid and should never be used for inference, but may
be useful in some cases for diagnosing issues.
# NOT RUN {## A previously run fitted TMB modelfit <- readRDS(system.file('examples', 'fit_tmb.RDS', package='adnuts'))
post <- extract_samples(fit)
tail(apply(post, 2, median))
# }