[R] ANCOVA in S-plus/R?

Richard M. Heiberger rmh at temple.edu
Fri Jun 2 21:59:30 CEST 2006


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)



More information about the R-help mailing list