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?
Yes. One way is to use anova(res1, type="marginal"). Read the help page and the book (or any decent linear models book). Andy> -----Original Message----- > From: Mahbub Latif [mailto:ahmlatif at yahoo.com] > Sent: Thursday, August 21, 2003 12:51 PM > To: r-help at stat.math.ethz.ch > Subject: [R] anova(lme object) > > > 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 >------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.
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