[R] mcmcsamp() in lmer

Spencer Graves spencer.graves at pdf.com
Sat Jan 21 21:31:58 CET 2006


Dear Prof. Gelman:

	  Thanks for providing such a simple, replicable example.  I got the 
same results you describe under Windows XP Pro with:
 > sessionInfo()
R version 2.2.1, 2005-12-20, i386-pc-mingw32

attached base packages:
[1] "methods"   "stats"     "graphics"  "grDevices" "utils"     "datasets"
[7] "base"

other attached packages:
      lme4   lattice    Matrix
"0.995-1" "0.12-11" "0.995-1"

	  Unfortunately, I'm missing something in my attempts to move beyond 
this.  First, I tried "traceback()", which gave me a standard 
cryptogram, which I couldn't decypher.  Then I typed "mcmcsamp" and 
learned that it consists solely of a call to 
'standardGeneric("mcmcsamp")'.  The help file for 'standardGeneric' sent 
me to "?GenericFunctions", which sent me further to "showMethods", which 
  produced the following:

showMethods("mcmcsamp")

Function "mcmcsamp":
object = "mer"
object = "lmer"
     (inherited from object = "mer")

	  Then I confirmed that the object "M1" created by the "lmer" call 
indeed had class "lmer".  From there, I tried several things without 
success.  The help("GenericFunctions") file mentioned 'dumpMethod' and 
'dumpMethods'.

 > dumpMethods("mcmcsamp") # produced nothing I could find.
 > dumpMethods("mcmcsamp", file="mcmcsamp.R")
# produced a file named "mcmcsamp.R" of official length 0 KB
# containing nothing, as far as I could tell.
 > dumpMethods("mcmcsamp", file="mcmcsamp.R", signature="lmer")
# also generated an empty file.

 > dumpMethod("mcmcsamp", "lmer")
[1] "mcmcsamp.lmer.R"
# Produced a file 'mcmcsamp.lmer.R' in the working directory,
#which contained only the following:

setMethod("mcmcsamp", "lmer",
NULL
)

	  I also tried 'trace(mcmcsamp)' and 'trace("mcmcsamp", browser, exit = 
browser)' before running the function giving the error message.  Nothing 
I saw from that seemed useful.

	  I'd be much obliged to anyone who could help understand how I could 
diagnose this issue.

	  Best Wishes,
	  Spencer Graves	

Andrew Gelman wrote:

> I am working with lmer() in the latest release of Matrix, doing various 
> things including writing a function called mcsamp() that acts as a 
> wrapper for mcmcsamp() and automatically runs multiple chains, diagnoses 
> convergence, and stores the result as a bugs object so it can be 
> plotted.  I recognize that at this point, mcmcsamp() is somewhat of a 
> placeholder (since it doesn't work on a lot of models) but I'm sure it 
> will continue to be improved so I'd like to be able to work with it, as 
> a starting point if necessary.
> 
> Anyway, I couldn't get mcmcsamp() to work with the saveb=TRUE option.  
> Here's a simple example:
> 
> y <- 1:10
> group <- rep (c(1,2), c(5,5))
> M1 <- lmer (y ~ 1 + (1 | group))   # works fine
> mcmcsamp (M1)                         # works fine
> mcmcsamp (M1, saveb=TRUE)
> 
> This last gives an error message:
> 
> Error in "colnames<-"(`*tmp*`, value = c("(Intercept)", "log(sigma^2)",  :
>         length of 'dimnames' [2] not equal to array extent
> 
> Thanks for your help.
> Andrew
>




More information about the R-help mailing list