[R] Using lme (nlme) to find the conditional variance of therandom effects

Rick Bilonick bilonickra at upmc.edu
Tue Nov 13 08:02:02 CET 2007


On Tue, 2007-11-13 at 01:03 -0500, Rick Bilonick wrote:

> 
> Is there some way to get ranef with postVar=TRUE to show what the
> variances are, or what the lower and upper bounds are? qqmath makes nice
> plots but I need to obtain the numerical values.
> 
> Rick B.
> 
I found a way:

attr(ranef(lmer.13,postVar=TRUE)[[2]],"postVar")

But I still don't understand why it's not OK to access the bVar slot
directly. 

Also, the code I originally showed and the results from ranef are very
similar with a correlation of 0.9983 (it varies very slightly from
subject to subject):

>
round(data.frame(a=as.numeric(lmer.13 at bVar[[2]]*(attr(VarCorr(lmer.13),"sc")^2)[1]),
  b=as.numeric(attr(ranef(lmer.13,postVar=TRUE)[[2]],"postVar"))),10)
          a        b
1  5.41e-08 5.44e-08
2  4.77e-08 4.83e-08
3  6.24e-08 6.25e-08
4  4.44e-08 4.52e-08
5  6.50e-08 6.50e-08
6  2.67e-08 2.92e-08
7  5.07e-08 5.12e-08
8  6.43e-08 6.43e-08
9  3.64e-08 3.79e-08
10 4.86e-08 4.92e-08
11 6.33e-08 6.33e-08
12 3.44e-08 3.60e-08
13 4.16e-08 4.26e-08
14 3.69e-08 3.83e-08
15 5.96e-08 5.97e-08
16 6.46e-08 6.46e-08
17 3.28e-08 3.46e-08
18 4.71e-08 4.77e-08
19 5.18e-08 5.22e-08
20 2.81e-08 3.04e-08
21 3.97e-08 4.09e-08
22 5.70e-08 5.72e-08
23 6.06e-08 6.07e-08
24 3.23e-08 3.42e-08
25 4.94e-08 4.99e-08
26 5.35e-08 5.38e-08
27 3.86e-08 3.98e-08
28 6.73e-08 6.73e-08
29 4.68e-08 4.74e-08
30 6.15e-08 6.16e-08
31 4.67e-08 4.74e-08
32 2.04e-08 2.37e-08
33 3.45e-08 3.61e-08
34 6.28e-08 6.29e-08
35 5.53e-08 5.55e-08

Not sure why they are not exactly the same.

Rick B.



More information about the R-help mailing list