[R] summary of aov fit on a contrast basis

J.Sobieszek@elka.pw.edu.pl J.Sobieszek at elka.pw.edu.pl
Tue Oct 23 10:47:16 CEST 2001


Hello,

In a book (David W. Stockburger, "Multivariate Statistics: Concepts,
Models, and Applications", chapter 12 "Contrasts, Special and
Otherwise", available online at http://www.psychstat.smsu.edu/multibook)
I've found some examples of doing analysis of variance on a contrast
basis.

I attach my solution (in R, the book uses SPSS) to this problem.

Am I computing the same thing, and is there a simpler way of doing that?

I would greatly appreciate any comments.

Thanks,

Jarek
-------------- next part --------------
# the data

x <- data.frame(G = factor(c(rep(1, 3), rep(2, 3), rep(3, 3), rep(4, 3), rep(5, 3), rep(6, 3))), X = c(1, 2, 3, 5, 6, 7, 9, 10, 11, 1, 2, 3, 1, 2, 3, 1, 2, 3))

# model matrix using contrasts:
# c0:  1  1  1  1  1  1
# c1:  2  2 -1 -1 -1 -1
# c2:  0  0  3 -1 -1 -1
# c3:  1 -1  0  0  0  0
# c4:  0  0  0 -2  1  1
# c5:  0  0  0  0  1 -1

CG <- matrix(c(rep(2, 6), rep(-1, 12), rep(0, 6), rep(3, 3), rep(-1, 9), rep(1, 3), rep(-1, 3), rep(0, 21), rep(-2, 3), rep(1, 6), rep(0, 12), rep(1, 3), rep(-1, 3)), ncol = 5, nrow = 18)

# fit the aov model (intercept instead of c0, to stop printing of c0's aov)

x.aov <- aov(x$X ~ CG[,1] + CG[,2] + CG[,3] + CG[,4] + CG[,5], x = T)

# display summary

summary(x.aov)

# check model matrix

x.aov$x


More information about the R-help mailing list