Multivariate Analysis of Variance

In R you first need to import datafile "BodyMeasures.txt", define n to represent the sample size, and group your response variables into a set using cbind.

> bodyMeasures <- read.table("/BodyMeasures.txt", header=TRUE, sep=",", na.strings="NA", dec=".")
> n<-length(bodyMeasures$Sex)
> bodyMeasures$Ys <- with(bodyMeasures,cbind(Mass,Fore,Bicep,Chest,Neck,Shoulder,Waist,Height,Calf,Thigh,Head))

Perform a MANOVA, report Pillai's trace, and include univariate tests on each measure

> fit_manova <- manova(Ys ~ Sex, data = bodyMeasures)
> summary(fit_manova)
> summary.aov(fit_manova)

Obtain the Matrix of error sums of squares and crossproducts (E) and the Matrix of model sums of squares and crossproducts (H) and report them

> E <- (n-1)*cov(fit_manova$residuals)
> E
> H <- (n-1)*cov(fit_manova$fitted.values)
> H

You can obtain for the Eigenvalues after solving H for E and the Eigenvectors via lda (which requires library MASS).

> roots <- eigen(H%*%solve(E))
> roots$values
> library(MASS)
> fit_lda <- lda(bodyMeasures$Ys,bodyMeasures$Sex)
> fit_lda

You can get a canonical centroid plot of this ananlysis using procedure cca (which requires library vegan).

> install.packages("vegan")
> library(vegan)
> cca.1 <- cca(bodyMeasures[,-1] ~ bodyMeasures$Sex)
> cca1.plot <- plot(cca.1)


last modified: 2/28/13