[R-sig-ME] p-values from lme::anova VS fixed-effects of lme

Karl Ove Hufthammer karl at huftis.org
Sun Dec 11 11:08:55 CET 2016


K Imran M skreiv 10. des. 2016 10:57:
> #### LME ######
>
> res <- lme(distance ~ age*Sex, random = ~ 1 | Subject, data = Orthodont)
>
> summary(res)
> […]
> Next, if I run 'anova(res)', I would obtain this
> […]
> I do not understand why the p-values for age and age:Sex (from anova) are
> similar with (lme::anova) BUT for sex: it is different (anova, p-val =
> 0.0054 vs lme::anova, p-val = 0.508).

The P-values are only identical for the interaction, *not* for age and 
*not* for Sex. The P-values for age just happened to both be very small. 
It’s easier to see this for a smaller dataset, with larger P-values:

     set.seed(1)
     d = Orthodont[sample(nrow(Orthodont), 20),]
     res = lme(distance ~ age*Sex, random = ~ 1 | Subject, data = d)

Now, summary(res) gives us:

                   Value Std.Error DF   t-value p-value
(Intercept)   19.259688 1.7255889 13 11.161226  0.0000
age            0.581252 0.1428037  3  4.070286  0.0268
SexFemale     -1.859006 2.3131153 13 -0.803681  0.4360
age:SexFemale -0.224017 0.1865328  3 -1.200955  0.3159

while anova(res) gives us:

             numDF denDF   F-value p-value
(Intercept)     1    13 1306.1220  <.0001
age             1     3   24.4811  0.0158
Sex             1    13   10.3881  0.0067
age:Sex         1     3    1.4423  0.3159

So only the interaction age:Sex gives the same P-value. The reason is 
that anova(res) gives the *sequential* tests (first the effect of age, 
then the effect of Sex given age, and then the effect of age:Sex given 
age and sex). Only the last test will be identical.

For  a similar test using anova(), you have to request marginal tests:

 > anova(res, type="marginal")
             numDF denDF   F-value p-value
(Intercept)     1    13 124.57297  <.0001
age             1     3  16.56723  0.0268
Sex             1    13   0.64590  0.4360
age:Sex         1     3   1.44229  0.3159

Mind you, the marginal tests (usually) don’t make much sense when you 
have an interaction. In your original example, the marginal P-value of 
0.51 for ‘Sex’ does *not* mean that sex doesn’t have an effect on the 
outcome variable. Since the age:Sex interaction is statistically 
significant (P-value ~0.01), Sex *obviously* has en effect; it’s just 
that the effect of sex depends on the age of the individual. And the 
P-values for the ‘marginal effects’ depend very much on the 
parametrisation. For example, if you change ‘age’ by adding or 
subtracting a constant (e.g. instead of measuring age as ‘years from 
birth’, you measure it as ‘years since starting school’ or ‘years until 
the person turns eighteen’), the ‘marginal’ P-value for ‘Sex’ will 
change (perhaps to a very low or high P-value).

-- 
Karl Ove Hufthammer



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