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

Andrew Beckerman a.beckerman at sheffield.ac.uk
Thu Apr 3 18:10:09 CEST 2008


Dear all -

Given Hank's comment below, I want to emphasize that I am not aiming  
to get into the rather enjoyable df debate...i.e. "how" or even  
whether to calculate df....

Lets assume that we are going to use the df = intercept + betas+  
random effects levels(?) + a term for the residual variance.

I was curious as to whether there was a concious decision made between  
lme and lmer, and if so, whether there is something to the "variable"  
difference between them as indicated by the code for the two datasets  
in the original posting.

A

---------------------------------------------------------------------------------
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/
----------------------------------------------------------------------------------


On 3 Apr 2008, at 15:57, MHH Stevens wrote:
> Hi Andrew,
> Welcome to the hornets' nest.
> Hank
> On Apr 3, 2008, at 10:43 AM, Andrew Beckerman wrote:
>> 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/
>>
>> _______________________________________________
>> R-sig-mixed-models at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> Dr. Hank Stevens, Assistant Professor
> 338 Pearson Hall
> Botany Department
> Miami University
> Oxford, OH 45056
>
> Office: (513) 529-4206
> Lab: (513) 529-4262
> FAX: (513) 529-4243
> http://www.cas.muohio.edu/~stevenmh/
> http://www.cas.muohio.edu/ecology
> http://www.muohio.edu/botany/
>
> "If the stars should appear one night in a thousand years, how would  
> men
> believe and adore." -Ralph Waldo Emerson, writer and philosopher  
> (1803-1882)
>
>
>
>
>
>




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