`tidy.mcmc.list` is a function that behaves like those from `broom`. It takes an mcmc.list object from `coda.samples` and return a data frame that summarises each parameters with its mean and quantiles and returns the output as a data.table object. This can be called as `tidy`. Currently summarises over all chains.

# S3 method for mcmc.list
tidy(x, conf_level = 0.95, chain = FALSE,
  colnames = NULL, ...)

Arguments

x

object of class "mcmc.list", as you would find with fitting a model using `jags.model()`, and `coda.samples`.

conf_level

level of the credible interval to be calculuated

chain

whether or not to summarise each parameter for each chain

colnames

which parameters we want from `mcmc_object`, if `NULL` then all columns get selected

...

extra arguments

Value

a data.table containing parameter summaries

Examples

library(coda) data(line) tidy(line)
#> parameter mean sd 2.5% median 97.5% #> 1: alpha 2.9875644 0.4983950 1.9650403 3.0188300 3.876589 #> 2: beta 0.7991864 0.3366834 0.1430713 0.7962500 1.469723 #> 3: sigma 0.9680519 0.7413014 0.4249618 0.7911975 2.559520
# Optionally ask for a subset of parameters with a vector of `colnames`, # and summarise for each chain: tidy(line, chain = TRUE, colnames=c("alpha"))
#> parameter chain mean sd 2.5% median 97.5% #> 1: alpha 1 2.982615 0.5313900 2.085719 2.973115 3.838839 #> 2: alpha 2 2.992514 0.4643476 1.965040 3.063630 3.890256