Re: [R] ANCOVA in S-plus/R?

From: Richard M. Heiberger <rmh_at_temple.edu>
Date: Sat 03 Jun 2006 - 05:59:30 EST


To get the ANCOVA table you need to look at the anova() function.

The variables T and L must be factors to get the multi-degree-of-freedom anova tables you are looking for.

Order matters. You get the same residual, but the sequential sums of squares differ.

bt.aov <- aov(E ~ B + T)
anova(bt.aov)
gives you the (t-1)df test of common intercept vs variable intercept. This is equivalent to comparing the adjusted means.

tb.aov <- aov(E ~ T + B)
anova(tb.aov)
gives you the 1df test of 0 slope (ordinary ANOVA) vs non-zero common slope.

lm() and aov() are essentially the same program. The default output is different.

When you bring in the blocking effect of hospital, you will most likely want that sequentially first.

lbt.aov <- aov(E ~ L + B + T)
anova(lbt.aov)

If you want to test for interaction with the hospital effect, you can use

l.bt.aov <- aov(E ~ L * (B + T))
anova(l.bt.aov)



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 Received on Sat Jun 03 06:06:05 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 03 Jun 2006 - 06:10:30 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.