[R] Coda not providing summary on mcmc object

Ben Bolker bolker at ufl.edu
Tue Jul 1 02:14:27 CEST 2008

smith_cc <smith_cc <at> yahoo.com> writes:

> The object is a mcmc sample from lmer. I am using R v2.7.1. Please let me
> know what additional information I can provide, hopefully I am just making a
> simple mistake. Thanks in advance!
> > data(ratdrink, package = 'faraway')
> > rd.er <- lmer(wt ~ weeks*treat + (1 | subject), data = ratdrink)
> > rd.mc <- mcmcsamp(rd.er, 10000)
> > library(coda)
> Loading required package: lattice
> > summary(rd.mc)
>  Length   Class    Mode 
>       1 merMCMC      S4 
> > HPDinterval(rd.mc)
> Error in UseMethod("HPDinterval") : 
>   no applicable method for "HPDinterval"

   I don't think it should necessarily have been obvious,
but help("merMCMC-class") suggests that lme4 contains
its own methods for doing HPDinterval calcs.  Furthermore,
loading coda after lme4 gives the following warning

	The following object(s) are masked from package:lme4 :


If you really want HPDintervals from coda, it looks like
you can do


or if you want to use lme4's HPDinterval while
coda is loaded, do


  (I don't quite know why lme4 is including its own
calculations rather than just allowing conversion to
coda objects -- maybe they don't want the dependency)

  If you have further questions it might make sense
to send them to r-sig-mixed ...

  Ben Bolker

More information about the R-help mailing list