Hi, I use lme to fit models like R> res1 <- lme(y~A+B, data=mydata, random=~1|subject) R> res2 <- lme(y~B+A, data=mydata, random=~1|subject) (only difference between these two models are the sequence in which the indep variables are written in formula) where y is continuous and A, B, and subject are factors. To get ANOVA table I used R> anova(res1) R> anova(res2) and found ANOVA tables corresponding to these two models are different. Is there any way I can get similar ANOVA tables from lme objects of this type?
anova(lme object)
6 messages · Mahbub Latif, Brian Ripley, Bjørn-Helge Mevik +1 more
On Thu, 21 Aug 2003, Mahbub Latif wrote:
Hi, I use lme to fit models like R> res1 <- lme(y~A+B, data=mydata, random=~1|subject) R> res2 <- lme(y~B+A, data=mydata, random=~1|subject) (only difference between these two models are the sequence in which the indep variables are written in formula) where y is continuous and A, B, and subject are factors. To get ANOVA table I used R> anova(res1) R> anova(res2) and found ANOVA tables corresponding to these two models are different. Is there any way I can get similar ANOVA tables from lme objects of this type?
Those are *sequential* anova tables, so should be different. Read the help page ?anova.lme to find the answer to your question. Hint: argument `type' may help.
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
The different answers reflect a lack of symmetry in the data set. The standard "A+B" anova evaluates the effect of A by itself and B given A. The other evalutes the effect of B by itself plus A given B. They answer different questions. If you want the same answer from "A+B" as from "B+A", you have to be clearer about what you want. For more discussion of that, see any good book on analysis of variance, including discussions of Types II and III sums of squares, e.g., from "www.r-project.org" -> search -> R site search. Judging from what they did, it seems apparent that the R developers and the S and S-Plus developers before them felt that it was best to report results in this way. hope this helps. spencer graves
Mahbub Latif wrote:
Hi, I use lme to fit models like R> res1 <- lme(y~A+B, data=mydata, random=~1|subject) R> res2 <- lme(y~B+A, data=mydata, random=~1|subject) (only difference between these two models are the sequence in which the indep variables are written in formula) where y is continuous and A, B, and subject are factors. To get ANOVA table I used R> anova(res1) R> anova(res2) and found ANOVA tables corresponding to these two models are different. Is there any way I can get similar ANOVA tables from lme objects of this type?
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
It is documented in ?anova.lme:
anova(res1, type="marginal")
and
anova(res2, type="marginal")
should give equivalent tables.
Bj?rn-Helge Mevik
You need to say "library(nlme)" first. Without that, "?anove.lme" [in R
1.7.1 under Windows 2000] and produced for me the following:
Error in help("anova.lme", htmlhelp = FALSE) :
No documentation for `anova.lme' in specified packages and libraries:
you could try `help.search("anova.lme")'
'help.search("anova.lme")' says anova.lme is in package nlme.
hope this helps. spencer gravesw
Bj?rn-Helge Mevik wrote:
It is documented in ?anova.lme:
anova(res1, type="marginal")
and
anova(res2, type="marginal")
should give equivalent tables.
Spencer Graves <spencer.graves at PDF.COM> writes:
You need to say "library(nlme)" first.
Of course. But since he has alreade used lme to fit the models, he must have loaded the library already. :-)
Bj?rn-Helge Mevik