extract.runjags: Extract peripheral information from runjags objects

View source: R/extract.runjags.R

extract.runjagsR Documentation

Extract peripheral information from runjags objects


Objects of class 'runjags' are produced by run.jags, results.jags and autorun.jags, and contain the MCMC chains as well as all information required to extend the simulation. This function allows specific information to be extracted from these functions. For other utility methods for the runjags class, see runjags-class.


## S3 method for class 'runjags'
extract(x, what, force.resample = FALSE, ...)



an object of class runjags.


the information contained in the runjags object to be extracted. See the details section for the available options.


option to re-draw new deviance/DIC/PED etc samples from the model (using dic.samples) rather than using any statistics that may already be available from the saved runjags object


additional options to be passed to dic.samples


The supported options for the 'what' argument are as follows:

  • crosscorr - the cross-correlation matrix

  • summary - the same as the summary method for runjags object

  • model - the model

  • data - the data

  • end.state - the model state at the last iteration (or initial values for non-updated models) which will be used to start an extended simulation

  • samplers - a matrix giving the sampler used for stochastic nodes (not available for all models)

  • stochastic - a logical vector of length equal to the number of variables indicating which variables are stochastic, with NA values for variables that are stochastic in one chain but not others - the return value of this can be passed to the 'vars' argument for combine.mcmc etc functions

  • dic - the DIC, as returned by dic.samples

  • dic - the PED, as returned by dic.samples with type="popt"

  • sum.deviance - the sum of the mean estimated deviance for each stochastic variable

  • sum.pd - the sum of the mean estimated pD for each stochastic variable

  • sum.popt - the sum of the mean estimated pOpt for each stochastic variable

  • mean.deviance - the mean estimated pD for each stochastic variable

  • mean.pd - the mean estimated pD for each stochastic variable

  • mean.popt - the mean estimated pOpt for each stochastic variable

  • full.deviance - the sum of the model deviance at each iteration (for each chain)

  • full.pd - the sum of the estimated pD at each iteration

Note that for the deviance/DIC related parameters, these will be extracted from the available information if possible, or otherwise re-sampled.


Matthew J. Denwood (2016). runjags: An R Package Providing Interface Utilities, Model Templates, Parallel Computing Methods and Additional Distributions for MCMC Models in JAGS. Journal of Statistical Software, 71(9), 1-25. doi:10.18637/jss.v071.i09

See Also

runjags-class for additional methods for runjags objects, add.summary for details on plot, print and summary methods for runjags class objects, runjags.options for general options available, and run.jags and autorun.jags for the functions that create objects of this class.

runjags documentation built on April 15, 2022, 5:05 p.m.