[R] gelman.diag question

Icabalceta, Jorge L. Icabalceta_j at wlf.state.la.us
Wed Feb 11 20:38:15 CET 2004

Dear Friends,
I am trying to use the gelman-rubin convergence test. I generated a matrix
samp[10,000x86] with the gibbs sampler. the test requires the creation of
"mcmc" objects. Since I don't know how to define samp as a "mcmc" object, I
tried to create one mcmc object by means of the mcmc() function. With this
function I tried to create a mcmc object dul from samp but I got the message
below. What am I doing wrong? 
> dim(samp)
[1] 10000    86
> dul<-mcmc(b1<-samp[,1],start=1, end=10000, thin=10)
Error in data[1:nobs, , drop = FALSE] : incorrect number of dimensions

Then, as described below,I tried other way to create the mcmc object  but I
get the message "Error in gelman.diag(dul3) : You need at least two chains".
I think I am not understanding how the Gelman-Rubin test works in R. Could
you give me a small example. 

> dul2<-mcmc(b1<-as.matrix(samp[,1]),start=1, end=10000, thin=10)
> dul3<-matrix(1000,2,c(dul,dul2))
> is.mcmc(dul3)
> dul3<-as.mcmc(dul3)
> is.mcmc(dul3)
[1] TRUE
> gelman.diag(dul3)
Error in gelman.diag(dul3) : You need at least two chains

I really appreciate your patience, help, and time,

More information about the R-help mailing list