[R-sig-ME] lme and lmer

Viechtbauer Wolfgang (STAT) wolfgang.viechtbauer at maastrichtuniversity.nl
Wed Jul 30 10:46:34 CEST 2014


If you want to fit the same models, you should use:

lme <- lme(fixed=Conc ~ Lab, data=coop, random = ~ 1 | Bat, subset=coop$Spc=="S1")

I am surprised that it even ran with 'random = ~ Bat' (lme in R throws an error).

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

> -----Original Message-----
> From: r-sig-mixed-models-bounces at r-project.org [mailto:r-sig-mixed-
> models-bounces at r-project.org] On Behalf Of Nicholas Burgoyne
> Sent: Wednesday, July 30, 2014 10:26
> To: r-sig-mixed-models at r-project.org
> Subject: [R-sig-ME] lme and lmer
> 
> Dear all,
> 
> I have been kindly redirected here by Ben Bolker, thank you for your
> assistance so far!
> 
> I apologise for posting what is probably quite a benign query, but for
> the life of me I can't find an answer.
> 
> I have been asked to explain the differences in the variance-covariance
> data in an identical test in Splus (lme) and R (lmer in lme4).
> 
> The input data is standard (from MASS), and identical (I've checked), the
> test is as similar as I can make it (code below).
> 
> The same output (to a high degree of precision) is obtained for all of
> the output values (not just that displaced here), expect for the vcov
> data for the Intercept with itself. The effect is therefore that the
> standard deviations of the fixed values are quite different!
> 
> I am using splus 6.2, R 3.0.2 and lme4 v 1.1-7 (see sessionInfo dump
> later on), the contrasts in splus are set to treatment/poly.
> 
> Any advice you could give me would be very helpful.
> 
> Kind regards,
> 
> Nick Burgoyne
> 
> #########
> #In Spus#
> #########
> >options(contrasts=c("contr.treatment", "contr.poly"))
> >library(MASS)
> >coop <- coop
> >lme <- lme(fixed=Conc ~ Lab, data=coop, random = ~ Bat,
> subset=coop$Spc=="S1")
> > lme
> Linear mixed-effects model fit by REML
>   Data: coop
>   Subset: coop$Spc == "S1"
>   Log-restricted-likelihood: 20.27187
>   Fixed: Conc ~ Lab
>  (Intercept)      LabL2 LabL3 LabL4     LabL5     LabL6
>     0.319999 0.08166667  0.04  0.68 0.1233333 0.2033333
> 
> Random effects:
> Formula:  ~ Bat | 1
> Structure: General positive-definite
>                   StdDev   Corr
> (Intercept) 0.1401167895 (Intr) BatB2
>       BatB2 0.0001407246  0.000
>       BatB3 0.0003628541  0.000 -0.072
>    Residual 0.1029156551
> 
> Number of Observations: 36
> Number of Groups: 1
> > lme$varFix
>              (Intercept)        LabL2        LabL3        LabL4
> LabL5        LabL6
> (Intercept)  0.021398003 -0.001765272 -0.001765272 -0.001765272 -
> 0.001765272 -0.001765272
>       LabL2 -0.001765272  0.003530544  0.001765272  0.001765272
> 0.001765272  0.001765272
>       LabL3 -0.001765272  0.001765272  0.003530544  0.001765272
> 0.001765272  0.001765272
>       LabL4 -0.001765272  0.001765272  0.001765272  0.003530544
> 0.001765272  0.001765272
>      LabL5 -0.001765272  0.001765272  0.001765272  0.001765272
> 0.003530544  0.001765272
>       LabL6 -0.001765272  0.001765272  0.001765272  0.001765272
> 0.001765272  0.003530544
> 
> ######
> #In R#
> ######
> >library(lme4)
> >library(MASS)
> >coop <- coop
> >lme <- lmer(formula=Conc ~ Lab + (1|Bat),  data=coop,
> subset=coop$Spc=="S1")
> >lme
> Linear mixed model fit by REML ['lmerMod']
> Formula: Conc ~ Lab + (1 | Bat)
>    Data: coop
> Subset: coop$Spc == "S1"
> REML criterion at convergence: -40.5438
> Random effects:
> Groups   Name        Std.Dev.
> Bat      (Intercept) 0.0000
>  Residual             0.1029
> Number of obs: 36, groups:  Bat, 3
> Fixed Effects:
> (Intercept)        LabL2        LabL3        LabL4        LabL5
> LabL6
>     0.32000      0.08167      0.04000      0.68000      0.12333
> 0.20333
> >vcov(lme)
> 6 x 6 Matrix of class "dpoMatrix"
>              (Intercept)        LabL2        LabL3        LabL4
> LabL5
> (Intercept)  0.001765278 -0.001765278 -0.001765278 -0.001765278 -
> 0.001765278
> LabL2       -0.001765278  0.003530556  0.001765278  0.001765278
> 0.001765278
> LabL3       -0.001765278  0.001765278  0.003530556  0.001765278
> 0.001765278
> LabL4       -0.001765278  0.001765278  0.001765278  0.003530556
> 0.001765278
> LabL5       -0.001765278  0.001765278  0.001765278  0.001765278
> 0.003530556
> LabL6       -0.001765278  0.001765278  0.001765278  0.001765278
> 0.001765278
>                    LabL6
> (Intercept) -0.001765278
> LabL2        0.001765278
> LabL3        0.001765278
> LabL4        0.001765278
> LabL5        0.001765278
> LabL6        0.003530556
> 
> > sessionInfo()
> R version 3.0.2 (2013-09-25)
> Platform: i386-w64-mingw32/i386 (32-bit)
> 
> locale:
> [1] LC_COLLATE=English_United Kingdom.1252
> [2] LC_CTYPE=English_United Kingdom.1252
> [3] LC_MONETARY=English_United Kingdom.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United Kingdom.1252
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> other attached packages:
> [1] MASS_7.3-29  lme4_1.1-7   Rcpp_0.11.2  Matrix_1.1-4
> 
> loaded via a namespace (and not attached):
> [1] grid_3.0.2      lattice_0.20-29 minqa_1.2.3     nlme_3.1-111
> [5] nloptr_1.0.0    splines_3.0.2   tools_3.0.2
> 
> --
> Nicholas Burgoyne
> E:nburgoyne at mango-solutions.com	T:+44 (0)1249 705 450
> W:www.mango-solutions.com



More information about the R-sig-mixed-models mailing list