library(car)
data(Pottery2)
# contrasts for Kiln correspond to between Region [,1:2] and within Region [,3:4]
contrasts(Pottery2$Kiln)
pmod <-lm(cbind(Al,Fe,Mg,Ca,Na,K,Ti,Mn,Ba)~Kiln, data=Pottery2)
car::Anova(pmod)
# extract coefficient names for linearHypotheses
coefs <- rownames(coef(pmod))[-1]
# test differences among regions
linearHypothesis(pmod, coefs[1:2])
# test differences within regions B, C
linearHypothesis(pmod, coefs[3:4])
heplot(pmod, fill=c(TRUE,FALSE), hypotheses=list("Region" =coefs[1:2], "WithinBC"=coefs[3:4]))
# all pairwise views; note that Ba shows no effect
pairs(pmod, fill=c(TRUE,FALSE))
# canonical view, via candisc::heplot
if (require(candisc)) {
# canonical analysis: how many dimensions?
(pcan <- candisc(pmod))
heplot(pcan, scale=18, fill=c(TRUE,FALSE), var.col="darkgreen", var.lwd=2, var.cex=1.5)
if (FALSE) {
heplot3d(pcan, scale=8)
}
}
Run the code above in your browser using DataLab