[R] Contrasts for MANOVA
Andy Bunn
abunn at montana.edu
Sun Dec 21 21:58:33 CET 2003
Prof. Ripley: Thanks for the response.
My imperfect understanding is that contrasts are a special kind of linear
combination that can be done a priori.
Here's an example that is similar to what she wants to do:
## START EXAMPLE
# Toy data:
y1 <- rnorm(15,0,2)
y2 <- runif(15)
y3 <- rnorm(15,2,1)
x1 <- c(rep("long", 5), rep("medium", 5), rep("short", 5))
dat <- data.frame(y1, y2, y3, x1)
# The question is:
# Are the population mean vectors for the multivariate responses of
# y1, y2, & y3 of the "long" x1 samples significantly different
# from those of the combined "medium" and "short" x1 samples?
#Like so:
attach(dat)
# Get the mean for each predictor level for each response
mean.vec <- cbind(
c(mean(y1[x1 == "long"]), mean(y2[x1 == "long"]), mean(y3[x1 == "long"])),
c(mean(y1[x1 == "medium"]), mean(y2[x1 == "medium"]), mean(y3[x1 ==
"medium"])),
c(mean(y1[x1 == "short"]), mean(y2[x1 == "short"]), mean(y3[x1 == "short"]))
)
detach(dat)
mean.vec
#Ho: mean.vec[,1] == 1/2 * (mean.vec[,2] + mean.vec[,3])
## END EXAMPLE
The actual data she is using is 10 responses and three factor levels, e.g.,
nlevels = 3, 3, 4
I hope this is clear. Thanks for any guidance.
-Andy
More information about the R-help
mailing list