Purpose
To work out a MANOVA example

> library(HSAUR2)
> library(ggplot2)
> library(reshape)
> mydata <- skulls
> q1 <- qplot(epoch, mb, data = mydata, geom = "boxplot")
> q2 <- qplot(epoch, bh, data = mydata, geom = "boxplot")
> q3 <- qplot(epoch, bl, data = mydata, geom = "boxplot")
> q4 <- qplot(epoch, nh, data = mydata, geom = "boxplot")
> pushViewport(viewport(layout = grid.layout(2, 2)))
> vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)
> print(q1, vp = vplayout(1, 1))
> print(q2, vp = vplayout(1, 2))
> print(q3, vp = vplayout(2, 1))
> print(q4, vp = vplayout(2, 2))

MANOVA-003.jpg

> mydata1 <- melt(mydata, id.vars = 1)
> colnames(mydata1) <- c("epoch", "var", "value")
> q1 <- qplot(epoch, value, data = mydata1, facets = . ~ var, geom = "boxplot")
> print(q1)

MANOVA-004.jpg

> q2 <- qplot(var, value, data = mydata1, facets = . ~ epoch, geom = "boxplot")
> print(q2)

MANOVA-005.jpg

The above figure deceives eyes as it seems to suggest that there is no difference in means between various epochs

  1. But MANOVA test says something else
> skulls_manova <- manova(cbind(mb, bh, bl, nh) ~ epoch, data = skulls)

Pillai Test

> summary(skulls_manova, test = "Pillai")
           Df Pillai approx F num Df den Df    Pr(>F)
epoch       4 0.3533   3.5120     16    580 4.675e-06 ***
Residuals 145
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Wilks test

> summary(skulls_manova, test = "Wilks")
              Df  Wilks approx F num Df den Df   Pr(>F)
epoch       4.00 0.6636   3.9009  16.00 434.45 7.01e-07 ***
Residuals 145.00
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Hotelling-Lawley Test

> summary(skulls_manova, test = "Hotelling-Lawley")
           Df Hotelling-Lawley approx F num Df den Df    Pr(>F)
epoch       4           0.4818   4.2310     16    562 8.278e-08 ***
Residuals 145
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Roy Test

> summary(skulls_manova, test = "Roy")
           Df     Roy approx F num Df den Df    Pr(>F)
epoch       4  0.4251  15.4097      4    145 1.588e-10 ***
Residuals 145
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> summary.aov(skulls_manova)
 Response mb :
             Df  Sum Sq Mean Sq F value    Pr(>F)
epoch         4  502.83  125.71  5.9546 0.0001826 ***
Residuals   145 3061.07   21.11
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Response bh : Df Sum Sq Mean Sq F value Pr(>F) epoch 4 229.9 57.5 2.4474 0.04897 * Residuals 145 3405.3 23.5 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Response bl : Df Sum Sq Mean Sq F value Pr(>F) epoch 4 803.3 200.8 8.3057 4.636e-06 *** Residuals 145 3506.0 24.2 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Response nh : Df Sum Sq Mean Sq F value Pr(>F) epoch 4 61.20 15.30 1.507 0.2032 Residuals 145 1472.13 10.15