Re: [R] lme4 extracting individual variance components

From: Douglas Bates <dmbates_at_gmail.com>
Date: Sat 25 Jun 2005 - 00:51:14 EST

On 6/24/05, FabbroThomas <thomas.fabbro@unifr.ch> wrote:
> Hi,
> For further calculations I need to extract indivdual Variances of
> different random effects from a fitted model.
> I found out how to extract the correlations
> (VarCorr(m1)@reSumry$group1) but I was not able to find a way to
> extract the other components individually.

Then look at

str(VarCorr(m1))

to find out what the structure is. It contains a slot 'scale' which is the estimated standard error of the noise term and a slot called reSumry which is a list with components corresponding to the grouping factors. Each of those components has a slot named StdDev which gives the relative standard deviation (relative to the value of the scale slot).

> To extract the Residuals I tried: (ranef(m1)@ stdErr) which
> unfortunately did not work.
> Thank you very much for your help!
>
> Thomas
>
>
> My model:
>
> > m1<- lmer(y ~ trtt + (trtt-1|group3) + (trtt-1|group2) +
> (trtt-1|group1), d1)
> > m1
> Linear mixed-effects model fit by REML
> Formula: y ~ trtt + (trtt - 1 | group3) + (trtt - 1 | group2) + (trtt -
> 1 | group1)
> Data: d1
> AIC BIC logLik MLdeviance REMLdeviance
> 1819.454 2003.915 -874.7269 1736.421 1749.454
> Random effects:
> Groups Name Variance Std.Dev. Corr
> group1 trtt1/TR1 0.115094 0.33926
> trtt1/TR2 0.338576 0.58187 0.177
> trtt2/TR1 0.141726 0.37647 -0.002 -0.007
> trtt2/TR2 0.327869 0.57260 -0.007 -0.002 0.321
> group2 trtt1/TR1 0.026259 0.16205
> trtt1/TR2 0.021771 0.14755 0.325
> trtt2/TR1 0.025403 0.15938 0.898 0.062
> trtt2/TR2 0.024479 0.15646 0.048 0.012 0.156
> group3 trtt1/TR1 0.028206 0.16795
> trtt1/TR2 0.133718 0.36567 0.848
> trtt2/TR1 0.057741 0.24029 0.990 0.905
> trtt2/TR2 0.110075 0.33178 0.638 0.944 0.731
> Residual 0.021744 0.14746
> # of obs: 1437, groups: group1, 1088; group2, 31; group3, 3
>
> Fixed effects:
> Estimate Std. Error DF t value Pr(>|t|)
> (Intercept) 4.875320 0.102476 1433 47.575 < 2.2e-16 ***
> trtt1/TR2 -4.647211 0.149408 1433 -31.104 < 2.2e-16 ***
> trtt2/TR1 0.577186 0.052293 1433 11.037 < 2.2e-16 ***
> trtt2/TR2 -4.237753 0.166187 1433 -25.500 < 2.2e-16 ***
> ---
> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
>
>
> I am working with:
>
> R 2.1.0
> lme4 0.96-1
> Matrix 0.96-3
> lattice 0.11-6
> latticeExtra 0.1-3
>
> On Mac OS X 10.3.9
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jun 25 00:56:01 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:02 EST