[R] tests performed by anova

From: Isabelle Rivals <isabelle.rivals_at_espci.fr>
Date: Sat 29 Jul 2006 - 00:56:27 EST

Dear R-helpers,

In the case of two categorical factors, say a and b, once I have fixed the constrasts, the model matrix is set according to these contrasts with "lm", and the t-tests for the significance of the parameters provided by "summary" indeed concern the comparison of the model with each submodel obtained by removing the corresponding column of the model matrix. So :

options(contrasts=c("contr.sum", "contr.poly")) mod = lm(Y ~ a*b, x=TRUE)

provide the expected results.

When using "anova" for the corresponding two-way anova, I was expecting to obtain the p-values of the Fisher tests corresponding to :
a : the removal of the columns coding for factor a b : the removal of the columns coding for factor b a:b : the removal of the columns coding for the interaction of factors a and b BUT : print(anova(mod))

does not provide the expected results. Moreover, the results of "anova" do not depend on the contrasts, since setting

options(contrasts=c("contr.treeatment", "contr.poly"))

leads to the same result.

I manage to obtain the desired results by creating the submodels without the corresponding columns, and by comparing them with "anova" , for example :

xsub = mod$x[,-c(2)]
submod = lm(Y ~ xsub-1)

So my questions are :
1) is there a direct way to perform the anova I want ? 2) what does "anova" really test, and why is it independant from the chosen model matrix ?

Thanks in advance,


P.S. I do not directly see the answers to my questions in MASS by Venables and Ripley.

        [[alternative HTML version deleted]]

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Jul 29 02:22:15 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 29 Jul 2006 - 04:16:34 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.