[R] Finding covariance in a lmer mixed effects model

Viechtbauer Wolfgang (STAT) Wolfgang.Viechtbauer at STAT.unimaas.nl
Thu Nov 12 08:44:24 CET 2009


The way you have specified the model implies that the covariance is 0.

If you actually want to estimate the covariance, you need to use:

fm1 <- lmer(fpg ~ 1 + time + (time|ID), fpg_lme)

Best,

--
Wolfgang Viechtbauer                        http://www.wvbauer.com/
Department of Methodology and Statistics    Tel: +31 (0)43 388-2277
School for Public Health and Primary Care   Office Location:
Maastricht University, P.O. Box 616         Room B2.01 (second floor)
6200 MD Maastricht, The Netherlands         Debyeplein 1 (Randwyck)


----Original Message----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Kurt Smith Sent:
Thursday, November 12, 2009 05:56 To: r-help at r-project.org
Subject: [R] Finding covariance in a lmer mixed effects model

> I am having difficulty finding the covariance for the random effects
> in a mixed effects model. I fit this model: fm1 <-  lmer(fpg ~ 1 +
> time + (1|ID) + (0+time|ID),fpg_lme)
>
> and want to find the covariance between the time and intercept random
> effects.
>
> I tried using VarCorr (see below) but it does not give the covariance
> or correlation between the random effects. Am I doing something
> wrong?
>
> Thanks,
> Kurt
>
>> summary(fm1)
> Linear mixed model fit by REML
> Formula: fpg ~ 1 + time + (1 | ID) + (0 + time | ID)
>    Data: fpg_lme
>      AIC     BIC  logLik deviance REMLdev
>  1499289 1499339 -749639  1499259 1499279
> Random effects:
>  Groups   Name        Variance   Std.Dev.
>  ID       (Intercept) 1.0396e+03 32.2435465
>  ID       time        1.2199e-05  0.0034926
>  Residual             1.1241e+02 10.6025764
> Number of obs: 174042, groups: ID, 55526
>
> Fixed effects:
>              Estimate Std. Error t value
> (Intercept) 1.108e+02  1.421e-01   779.9
> time        2.106e-03  6.678e-05    31.5
>
> Correlation of Fixed Effects:
>      (Intr)
> time -0.163
>
>
>> VarCorr(fm1)
> $ID
>             (Intercept)
> (Intercept)    1039.646
> attr(,"stddev")
> (Intercept)
>    32.24355
> attr(,"correlation")
>             (Intercept)
> (Intercept)           1
>
> $ID
>              time
> time 1.219857e-05
> attr(,"stddev")
>        time
> 0.003492645
> attr(,"correlation")
>      time
> time    1
>
> attr(,"sc")
> sigmaREML
>  10.60258
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list