[R] lmer, MCMCsamp and ranef samples?

Jukka Koskela jukka.koskela at helsinki.fi
Sat Feb 19 09:25:33 CET 2011


I really hope sombody could help me with the following,

I'm having problems accessing the random effect samples following the  
example on MCMCsamp:

(fm1 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), sleepstudy))

set.seed(101); samp0 <- mcmcsamp(fm1, n = 1000, saveb=TRUE)

str(samp0)

Formal class 'merMCMC' [package "lme4"] with 9 slots
   ..@ Gp      : int [1:3] 0 18 36
   ..@ ST      : num [1:2, 1:1000] 0.98 0.234 1.097 0.258 0.915 ...
   ..@ call    : language lmer(formula = Reaction ~ Days + (1 |  
Subject) + (0 + Days |      Subject), data = sleepstudy)
   ..@ deviance: num [1:1000] 1752 1752 1753 1752 1752 ...
   ..@ dims    : Named int [1:18] 2 180 2 36 1 2 0 1 2 5 ...
   .. ..- attr(*, "names")= chr [1:18] "nt" "n" "p" "q" ...
   ..@ fixef   : num [1:2, 1:1000] 251.41 10.47 254.56 9.71 262.67 ...
   .. ..- attr(*, "dimnames")=List of 2
   .. .. ..$ : chr [1:2] "(Intercept)" "Days"
   .. .. ..$ : NULL
   ..@ nc      : int [1:2] 1 1
   ..@ ranef   : num [1:36, 1:1000] 1.51 -40.37 -39.18 24.52 22.91 ...
   ..@ sigma   : num [1, 1:1000] 25.6 23.6 22.9 22.1 26.2 ...



I assume that there is random effect samples for the intercept  
(1|Subject) and the slope (0+Days|Subject).

The trouble is that I would like to get the samp0 at ranef for the  
(0+Days|Subject) term, but I don't know how to separate the samples..

If I try for example:

samp0 at ranef[1,],

I get n=1000 samples for what? I think it is for the intercept term..


Jukka



More information about the R-help mailing list