Re: [R] Coda not providing summary on mcmc object

From: Ben Bolker <bolker_at_ufl.edu>
Date: Tue, 01 Jul 2008 00:14:27 +0000 (UTC)

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 :

         HPDinterval

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

HPDinterval(as.mcmc(as.matrix(rd.mc)))

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

lme4::HPDinterval(rd.mc)

  (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



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. Received on Tue 01 Jul 2008 - 00:20:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Jul 2008 - 00:31:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive