[R-sig-ME] logLik df in lme vs. lmer

Andrew Beckerman a.beckerman at sheffield.ac.uk
Thu Apr 3 16:43:55 CEST 2008


Dear all -

R 2.6.2, lme4 version 0.99875-9, OSX.

We have noticed that lme and lmer produce different estimates of the  
number of paramters in the estimation of the logLik.  While these are   
different, the logLik is not (good), but ensuing calculations of AIC  
can be.

According to some textbooks (i.e. Burnham and Anderson), the number of  
paramters is calcuated as the intercept + betas+ random effects levels  
(?) + a term for the residual variance.  In the example below  
(sleepstudy from lmer), that calculation results in df=5, as indicated  
in lmer but not in lme.

library(lme4)

wrk<-sleepstudy # data from lmer package

fm.lmer <- lmer(Reaction ~ Days + (Days|Subject), wrk,method="ML")
logLik(fm.lmer) # df = 5
fm.lmer
AIC(logLik(fm.lmer))

detach(package:lme4)

library(nlme)

fm.lme <- lme(Reaction ~ Days,random=~Days|Subject, wrk,method="ML")
summary(fm.lme)
logLik(fm.lme) # df=6
AIC(logLik(fm.lme))

However, we have also seen lmer appear to "underestimate" and lme get  
it right -

# continuing from above

wrk2<-Orthodont # data from nlme package
fm.lme2 <- lme(distance ~ age + Sex, data = wrk2, random = ~  
1,method="ML")
fm.lme2
logLik(fm.lme2) # df=5 (correct?)

detach(package:nlme)

library(lme4)

fm.lmer2 <- lmer(distance ~ age + Sex+(1|Subject), data = wrk2,  
method="ML")
fm.lmer2
logLik(fm.lmer2) # df=4 (now underestimated?)

Does anyone know what is going on?  Obviously, we can just specify the  
df in AIC calculations by hand, but AIC() uses the df from logLik (),  
which seems to vary.

I've noticed this question here as well.

http://tolstoy.newcastle.edu.au/R/e4/help/08/02/3988.html

Cheers
andrew


---------------------------------------------------------------------------------
Dr. Andrew Beckerman
Department of Animal and Plant Sciences, University of Sheffield,
Alfred Denny Building, Western Bank, Sheffield S10 2TN, UK
ph +44 (0)114 222 0026; fx +44 (0)114 222 0002
http://www.beckslab.staff.shef.ac.uk/




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