Skip to content

anova(lme object)

6 messages · Mahbub Latif, Brian Ripley, Bjørn-Helge Mevik +1 more

#
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?
#
On Thu, 21 Aug 2003, Mahbub Latif wrote:

            
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.
#
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:
#
It is documented in ?anova.lme:
and
should give equivalent tables.
#
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:
#
Spencer Graves <spencer.graves at PDF.COM> writes:
Of course.  But since he has alreade used lme to fit the models, he
must have loaded the library already.  :-)