[R] different DF in package nlme and lme4

Douglas Bates bates at stat.wisc.edu
Mon Jan 3 16:10:09 CET 2005


Christoph Buser wrote:
> Hi all
> 
> I tried to reproduce an example with lme and used the Orthodont
> dataset.
> 
> library(nlme)
> fm2a.1 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1 | Subject)
> anova(fm2a.1)
> 
>>            numDF denDF  F-value p-value
>>(Intercept)     1    80 4123.156  <.0001
>>age             1    80  114.838  <.0001
>>Sex             1    25    9.292  0.0054
> 
> 
> or alternatively (to get the same result)
> 
> fm2a.2 <- lme(distance ~ age + Sex, data = Orthodont, random = list(Subject = ~ 1))
> anova(fm2a.2)
> 
>>            numDF denDF  F-value p-value
>>(Intercept)     1    80 4123.156  <.0001
>>age             1    80  114.838  <.0001
>>Sex             1    25    9.292  0.0054
> 
> 
> ---------------------------------------------------------------
> Then I restarted!!! R to use the lme4 package instead of nlme.
> ---------------------------------------------------------------
> 
> library(lme4)
> fm2b.1 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1 | Subject)
> anova(fm2b.1)
> 
>>Analysis of Variance Table
>>    Df  Sum Sq Mean Sq   Denom  F value    Pr(>F)    
>>age  1 235.356 235.356 105.000 114.8383 < 2.2e-16 ***
>>Sex  1  19.044  19.044 105.000   9.2921  0.002912 ** 
> 
> 
> or alternatively (to get the same result)
> 
> fm2b.2 <- lme(distance ~ age + Sex, data = Orthodont, random = list(Subject = ~ 1anova(fm2b.2)
> 
>>Analysis of Variance Table
>>    Df  Sum Sq Mean Sq   Denom  F value    Pr(>F)    
>>age  1 235.356 235.356 105.000 114.8383 < 2.2e-16 ***
>>Sex  1  19.044  19.044 105.000   9.2921  0.002912 ** 
> 
> 
> 
> I got different DF for the denominator. Do I have to use lme in
> another way in the package lme4?
> 
> I use R 2.0.1 under linux and
> Package:       nlme
> Version:       3.1-53
> Date:          2004-11-03
> Package:       lme4
> Version:       0.6-11
> Date:          2004-12-16
> 
> Thanks for help.
> 
> Regards, 
> 
> Christoph Buser
> 

No.  The calculation of denominator degrees of freedom in lme4 is bogus 
and I believe this is documented.  Note that for all practical purposes 
there is very little difference between 25 and 100 denominator degrees 
of freedom.

lme4 is under development (and has been for a seemingly interminable 
period of time).  Getting the denominator degrees of freedom calculation 
"right" is way down the list of priorities.

Many people express dismay about the calculation of denominator degrees 
of freedom in all versions of lme4.  IIRC Frank Harrell characterizes 
this as one of the foremost deficiencies in R relative to SAS.  I don't 
agree that this is a glaring deficiency.  In fact I believe that there 
is no "correct" answer.  The F statistics in a mixed model do not have 
an F distribution under the null hypothesis.  It's all an approximation, 
which is why I don't stay up nights worrying about the exact details of 
the approximation.

My plan for lme4 is that one slot in the summary object for an lme model 
will be an incidence table of terms in the fixed effects versus grouping 
factors for the random effects.  This table will indicate whether a 
given term varies within groups defined by the grouping factor.  Anyone 
who wants to implement their personal favorite calculation of 
denominator degrees of freedom based on this table will be welcome to do so.

I personally think that tests on the fixed-effects terms will be better 
implemented using the restricted likelihood-ratio tests defined by 
Reinsel and Ahn rather than the Wald tests and the whole issue of 
denominator degrees of freedom may be moot.

My apologies if I seem to be peeved.  I am not upset by your question - 
it is an entirely reasonable question.  It is just that I have discussed 
the issue of denominator degrees of freedom too many times.

To me a more important objective of lme4 is to be able to handle random 
effects associated with crossed or partially crossed grouping factors. 
I believe that in those cases the calculation of denominator degrees of 
freedom will be very complicated and even more of an approximation than 
in the case of nested grouping factors.  This is why I would rather 
finesse the whole issue by using the Reinsel and Ahn approach.




More information about the R-help mailing list