Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mcmc.convert

Conversions of MCMC objects


Description

These are methods for the generic functions as.matrix(), as.array() and as.mcmc().

as.matrix() strips the MCMC attributes from an mcmc object and returns a matrix. If iters = TRUE then a column is added with the iteration number. For mcmc.list objects, the rows of multiple chains are concatenated and, if chains = TRUE a column is added with the chain number.

mcmc.list objects can be coerced to 3-dimensional arrays with the as.array() function.

An mcmc.list object with a single chain can be coerced to an mcmc object with as.mcmc(). If the argument has multiple chains, this causes an error.

Usage

## S3 method for class 'mcmc'
as.matrix(x, iters = FALSE, ...)
## S3 method for class 'mcmc.list'
as.matrix(x, iters = FALSE, chains = FALSE, ...)
## S3 method for class 'mcmc.list'
as.array(x, drop, ...)

Arguments

x

An mcmc or mcmc.list object

iters

logical flag: add column for iteration number?

chains

logical flag: add column for chain number? (if mcmc.list)

drop

logical flag: if TRUE the result is coerced to the lowest possible dimension

...

optional arguments to the various methods

See Also


coda

Output Analysis and Diagnostics for MCMC

v0.19-4
GPL (>= 2)
Authors
Martyn Plummer [aut, cre, trl], Nicky Best [aut], Kate Cowles [aut], Karen Vines [aut], Deepayan Sarkar [aut], Douglas Bates [aut], Russell Almond [aut], Arni Magnusson [aut]
Initial release
2020-09-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.