[R-sig-ME] extracting random effect stddev from glmer
Joshua Wiley
jwiley.psych at gmail.com
Mon May 14 01:56:45 CEST 2012
Hi Kathryn,
If you do:
str(VarCorr(pf1))
you will see that it is a list because you have multiple random
effects. attr(obj, "stddev") only works for the specific elements of
the list which have attributes. The overall list does not (okay, it
does, but not that one).
attr(VarCorr(pf1)$vblock, "stddev")
should work.
Alternately, something like:
sqrt(unlist(VarCorr(pf1)))
may work, to unlist the list (for your case I think it may return a
vector, but maybe something more complex if the elements had more than
one number in each). Then the square root of the variances is your
standard deviation.
Cheers,
Josh
On Sun, May 13, 2012 at 4:40 PM, Kathryn Benton
<benton at stat.berkeley.edu> wrote:
> Hi:
>
> I am attempting to extract the RE standard deviations from my glmer object. I've used the following code, but it gives cval "NULL".
>
> pf1 <- glmer(PfPrev ~ 1 + Age + I(Age^2) + SinWeek + CosWeek + ITN + (1|vblock) + (1|cblock), family = binomial, data = all.prev)
>
> ChildRE <- VarCorr(pf1)[1]
> cval <- attr(ChildRE, "stddev")
>
> I also tried:
>
> ChildRE <- VarCorr(pf1)
> cval <- attr(ChildRE, "sc")
>
> Thanks for your help.
>
> Kind regards,
>
> Katie Benton
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/
More information about the R-sig-mixed-models
mailing list