[R] Fwd: Converting a matrix to an mcmc object

Margaret Donald merricks.merricks at gmail.com
Wed Dec 2 03:47:47 CET 2015


---------- Forwarded message ----------
From: Margaret Donald <merricks.merricks at gmail.com>
Date: 1 December 2015 at 23:09
Subject: Re: [R] Converting a matrix to an mcmc object
To: Jim Lemon <drjimlemon at gmail.com>


Thanks, Jim.  It may well do, but I am struggling to see how to coerce a
matrix into three chains... I could reprogram the whole show run it in
WinBUGS or OpenBUGS and process the coda, but I would prefer not to.

Regards,
Margaret.

On 30 November 2015 at 17:31, Jim Lemon <drjimlemon at gmail.com> wrote:

> Hi Margaret,
> Doesn't the "mcmc" function in the "coda" package create an mcmc object
> from a matrix?
>
> Jim
>
>
> On Mon, Nov 30, 2015 at 9:44 AM, Margaret Donald <
> merricks.merricks at gmail.com> wrote:
>
>> Dear List,
>>
>> I am using R2jags and post process some mcmc objects to produce a new
>> object, which is currently a matrix, which replicates the shape of the
>> objects from which it is derived.
>>
>> I want to produce a Gelman-Rubin graph from its (implied) three chains,
>> but
>> I need to coerce the matrix into an mcmc object if I am to use gelman.plot
>> or gelman.diag from the R-package "coda".
>>
>> (The various mcmc functions in "coda" seem to work in the other
>> direction.....)
>>
>> Regards,
>> Margaret Donald
>>
>>
>>
>> --
>> Margaret Donald
>> Post Doctoral researcher
>> University of New South Wales
>> margaret.donald at unsw.edu.au
>> 0405 834 550
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>


-- 
Margaret Donald
Post Doctoral researcher
University of New South Wales
margaret.donald at unsw.edu.au
0405 834 550





Dear List,
>

I failed to make it to the help list.  I have gone to the latest version of
the r coda package,
and fail to find any help there as to how to coerce a vector (15000) or a
matrix (5000 x 3) into an mcmc object with a name (given by me) and having
three chains. I can get a single chain, but I want three.

I would appreciate an example of a matrix as described above and the code
needed to turn it into an mcmc object.   I could arduously produce coda
files and import them, but that seems ridiculous.

Regards

Margaret Donald

>
> I am using R2jags and post process some mcmc objects to produce a new
> object, which is currently a matrix, which replicates the shape of the
> objects from which it is derived.
>
> I want to produce a Gelman-Rubin graph from its (implied) three chains, but
> I need to coerce the matrix into an mcmc object if I am to use gelman.plot
> or gelman.diag from the R-package "coda".
>
> (The various mcmc functions in "coda" seem to work in the other
> direction.....)
>
> Regards,
> Margaret Donald
>
>
>


-- 
Margaret Donald
Post Doctoral researcher
University of New South Wales
margaret.donald at unsw.edu.au
0405 834 550

	[[alternative HTML version deleted]]



More information about the R-help mailing list