[R] MCMC object indexing

Robinson, David G drobin at sandia.gov
Thu Jan 20 16:18:02 CET 2011


Stoker, Ben wrote:
> A reproducible example would be very useful.  In general
> I find that I can just index an mcmc object as though it
> were a matrix, e.g.:
> 
> z <- cbind(a=runif(20),b=runif(20),c=runif(20))
> library(coda)
> m <- mcmc(data=z)
> t(apply(m,2,quantile,c(0.025,0.975)))
> 
>   If that sort of thing doesn't work for you, please
> post an example of what doesn't work ...
> 
>   Ben Bolker

Ben, thanks for the suggestion and it got me going the right direction.
FWIW-I did get an error from your suggestion, but it led me to find that I
had an mcmc.list object and not an mcmc object.  Once I got past that, your
suggestion worked perfectly. Thanks!



More information about the R-help mailing list