[R] How do you create a "MCMC" object?

Duncan Murdoch dmurdoch at pair.com
Thu Feb 12 20:27:53 CET 2004

On Thu, 12 Feb 2004 10:06:41 -0600, "Icabalceta, Jorge L."
<Icabalceta_j at wlf.state.la.us> wrote :

>I have been running a Gibbs Sampler to estimate levels of efficiency in the
>Louisiana Shrimp Industry. I created a matrix (samp) where I stored the
>results of each iteration for 86 variables. I run 10,000 iterations. So, the
>matrix samp is 10,000 x 86. I want to use the gelman-rubin test to check for
>convergence. To do that, I need at least two chains. If I run second chain
>with different starting values and seed, I could save to the matrix 'samp2'.
>So, I will have two matrices 10,000x86. I want to use the function
>gelman.diag(x, confidence = 0.95, transform=FALSE), where x: An 'mcmc.list'
>object with more than one chain, and with starting values that are
>overdispersed with respect to the posterior distribution. How do I create
>mcmc object from these matrices? I need to create an mcmc object with the
>two chains I have stored in 'samp' and 'samp2'.
>Thanks for your help and attention.

I think you're asking about functions from the coda package.

The normal way to create an MCMC object is to read BUGS output, but
it's probably not hard to create one from your own data.  There's a
function called "as.mcmc" which looks like it should do what you need;
if not, you might want to write to the coda maintainer, Martyn Plummer
<plummer at iarc.fr>.

Duncan Murdoch

More information about the R-help mailing list