[R] MCMCpack combining chains

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Feb 26 17:53:36 CET 2011



On 24.02.2011 17:48, Alan Kelly wrote:
> Deal all, as MCMClogit does not allow for the specification of several chains, I have run my model 3 times with different random number seeds and differently dispersed multivariate normal priors.
> For example:
> res1 = MCMClogit(y~x,b0=0,B0=0.001,data=mydat, burnin=500, mcmc=5500, seed=1234, thin=5)
> res2 = MCMClogit(y~x,b0=1,B0=0.01,data=mydat, burnin=500, mcmc=5500, seed=5678, thin=5)
> res3 = MCMClogit(y~x,b0=5,B0=0.0001,data=mydat, burnin=500, mcmc=5500, seed=91011, thin=5)
>
> Each result produces an object of class mcmc.
> In order to use the Gelman-Rubin diagnostic test via coda, I need to "combine" these 3 mcmc objects appropriately.  I thought that this would be possible using as.mcmc.list() as the function description says:
> The function ‘mcmc.list’ is used to represent parallel runs of the same chain, with different starting values and random seeds. The list must be balanced: each chain in the list must have the same iterations and the same variables.
> So I try the following:
> res123=as.mcmc.list(res1, res2, res3)


Use mcmc.list() rather than as.mcmc.list(). The latter is for 
conversion, not a constructor from separate mcmc objects.

Uwe Ligges




> class(res123)
> [1] "mcmc.list"
 >
> Then I try gelman.diag() from coda -
> gelman.diag(temp123)
> Error in gelman.diag(temp123) : You need at least two chains
>
> So, how may I combine the separate mcmc objects so that I have multiple chains?
> Many thanks,
> Alan Kelly
>
>
>
>
> 	[[alternative HTML version deleted]]
>
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.



More information about the R-help mailing list