0

Having just installed R version 3.0.1 on my Windows 7 machine to use package nlme, I've found a huge difference in the models fitted by the lme() function in package lme4. Note that these results also differ in that R 2.15.2 uses lme4 1.0-4, while R 3.0.1 uses lme4 1.1-6 (both installed using install.packages("lme4")).

A number of values are different by an order of magnitude (REML criterion, random effects, and most noticeably, ANOVA p value).

I assume this is a (major) bug, but I wanted to check with the community first. Also, feel free to migrate this question to CrossValidated, if it would be more appropriate.

Output from a simple design below.


Using R 2.15.2

version$major
## [1] "2"
version$minor
## [1] "15.2"
library(lme4)
## Warning: package 'lme4' was built under R version 2.15.3
## Loading required package: lattice
## Warning: package 'lattice' was built under R version 2.15.3
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 2.15.3
sessionInfo()$otherPkgs$lme4$Version
## [1] "1.0-4"

data = read.csv("correct_data.csv")

null_model = lmer(dv ~ (1 | subject) + (1 | target), data = data)
alt_model = lmer(dv ~ condition + (1 | subject) + (1 | target), data = data)

summary(alt_model)
## Linear mixed model fit by REML ['lmerMod']
## Formula: dv ~ condition + (1 | subject) + (1 | target) 
##    Data: data 
## 
## REML criterion at convergence: 486.9 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  subject  (Intercept) 0.00299  0.0547  
##  target   (Intercept) 0.00217  0.0465  
##  Residual             0.17733  0.4211  
## Number of obs: 423, groups: subject, 38; target, 7
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)   0.1185     0.0336    3.52
## condition     0.0983     0.0414    2.37
## 
## Correlation of Fixed Effects:
##           (Intr)
## condition -0.532

anova(null_model, alt_model)
## Data: data
## Models:
## null_model: dv ~ (1 | subject) + (1 | target)
## alt_model: dv ~ condition + (1 | subject) + (1 | target)
##            Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)  
## null_model  4 491 507   -241      483                          
## alt_model   5 487 507   -238      477  5.55      1      0.018 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Using R 3.0.1

version$major
## [1] "3"
version$minor
## [1] "1.0"
library(lme4)
## Loading required package: Matrix
## Loading required package: Rcpp
sessionInfo()$otherPkgs$lme4$Version
## [1] "1.1-6"

data = read.csv("correct_data.csv")

null_model = lmer(dv ~ (1 | subject) + (1 | target), data = data)
alt_model = lmer(dv ~ condition + (1 | subject) + (1 | target), data = data)

summary(alt_model)
## Linear mixed model fit by REML ['lmerMod']
## Formula: dv ~ condition + (1 | subject) + (1 | target)
##    Data: data
## 
## REML criterion at convergence: 5242
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.9112 -0.8148  0.0376  0.8111  1.9040 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  subject  (Intercept)   760     27.6   
##  target   (Intercept)   122     11.0   
##  Residual             13911    117.9   
## Number of obs: 423, groups: subject, 38; target, 7
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)    204.3        9.8   20.86
## condition       17.8       11.6    1.53
## 
## Correlation of Fixed Effects:
##           (Intr)
## condition -0.509

anova(null_model, alt_model)
## refitting model(s) with ML (instead of REML)
## Data: data
## Models:
## null_model: dv ~ (1 | subject) + (1 | target)
## alt_model: dv ~ condition + (1 | subject) + (1 | target)
##            Df  AIC  BIC logLik deviance Chisq Chi Df Pr(>Chisq)
## null_model  4 5265 5281  -2629     5257                        
## alt_model   5 5265 5285  -2627     5255  2.33      1       0.13
Eoin
  • 565
  • 3
  • 14
  • No warnings in either case? Could you please send a reproducible example to the package maintainers? – Ben Bolker Apr 25 '14 at 04:14
  • Yeah, of course, will do, once I'm back in the office. There are warnings about lme4, Matrix, and Lattice being built under R version 2.15.3 (when I run in 2.15.2), but interestingly, I seem to get the same (statistically significant) results running R 3.0.2 and lme4 1.1-6 on Ubuntu at home. – Eoin Apr 25 '14 at 13:53
  • 1
    Is lmer using the same optimizer in these two examples? I have seen different results from the bobyqa and nelder_mead optimizers and I seem to recall the default optimizer changed in lmer changed at one point. – Kevin Wright Nov 12 '15 at 23:46
  • Honestly, I don't know. I'm using R 3.2.2 and lme4 1.1-9 on both boxes now. That sounds like a plausible explanation though. – Eoin Nov 12 '15 at 23:50

0 Answers0