data(dogfood)
library(car)
library(candisc)
# make some boxplots
op <- par(mfrow = c(1,2))
boxplot(start ~ formula, data = dogfood)
points(start ~ formula, data = dogfood, pch=16, cex = 1.2)
boxplot(amount ~ formula, data = dogfood)
points(amount ~ formula, data = dogfood, pch=16, cex = 1.2)
par(op)
# setup contrasts to test interesting comparisons
C <- matrix(
c( 1, 1, -1, -1, #Ours vs. Theirs
0, 0, 1, -1, #Major vs. Alps
1, -1, 0, 0), #New vs. Old
nrow=4, ncol=3)
# assign these to the formula factor
contrasts(dogfood$formula) <- C
# re-fit the model
dogfood.mod <- lm(cbind(start, amount) ~ formula, data=dogfood)
dogfood.mod <- lm(cbind(start, amount) ~ formula, data=dogfood)
Anova(dogfood.mod)
# data ellipses
covEllipses(cbind(start, amount) ~ formula, data=dogfood,
fill = TRUE, fill.alpha = 0.1)
# test these contrasts with multivariate tests
linearHypothesis(dogfood.mod, "formula1", title="Ours vs. Theirs")
linearHypothesis(dogfood.mod, "formula2", title="Old vs. New")
linearHypothesis(dogfood.mod, "formula3", title="Alps vs. Major")
heplot(dogfood.mod, fill = TRUE, fill.alpha = 0.1)
# display contrasts in the heplot
hyp <- list("Ours/Theirs" = "formula1",
"Old/New" = "formula2")
heplot(dogfood.mod, hypotheses = hyp,
fill = TRUE, fill.alpha = 0.1)
dogfood.can <- candisc(dogfood.mod, data=dogfood)
heplot(dogfood.can,
fill = TRUE, fill.alpha = 0.1,
lwd = 2, var.lwd = 2, var.cex = 2)
Run the code above in your browser using DataLab