library(SPH.140.615)
summary(mosq)
## length individual cage
## Min. :49.30 1:6 A:8
## 1st Qu.:58.25 2:6 B:8
## Median :67.05 3:6 C:8
## Mean :66.63 4:6
## 3rd Qu.:72.03
## Max. :84.00
The nested ANOVA.
mosq.aov <- aov(length ~ cage / individual, data=mosq)
nested.anova(mosq.aov)
## Analysis of Variance Table
##
## Response: length
## Df Sum Sq Mean Sq F value Pr(>F)
## cage 2 665.68 332.84 1.7409 0.2295
## cage:individual 9 1720.68 191.19 146.8781 6.981e-11 ***
## Residuals 12 15.62 1.30
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
What happens when we use the average of the two measurements for each mosquito?
aves <- tapply(mosq$length, list(mosq$individual, mosq$cage), mean)
aves
## A B C
## 1 59.00 69.80 57.05
## 2 79.35 55.25 78.50
## 3 83.80 50.00 69.55
## 4 69.20 64.80 63.30
aves <- as.numeric(aves)
aves
## [1] 59.00 79.35 83.80 69.20 69.80 55.25 50.00 64.80 57.05 78.50 69.55 63.30
cage <- factor(rep(c("A","B","C"), each=4))
cage
## [1] A A A A B B B B C C C C
## Levels: A B C
anova(aov(aves ~ cage))
## Analysis of Variance Table
##
## Response: aves
## Df Sum Sq Mean Sq F value Pr(>F)
## cage 2 332.84 166.419 1.7409 0.2295
## Residuals 9 860.34 95.593
What happens when we ignore the cages, and just do the ANOVA with individual mosquitos as the groups?
ind <- factor(paste(as.character(mosq$cage), as.character(mosq$ind), sep=":"))
ind
## [1] A:1 A:1 A:2 A:2 A:3 A:3 A:4 A:4 B:1 B:1 B:2 B:2 B:3 B:3 B:4 B:4 C:1 C:1 C:2 C:2 C:3 C:3 C:4 C:4
## Levels: A:1 A:2 A:3 A:4 B:1 B:2 B:3 B:4 C:1 C:2 C:3 C:4
anova(aov(mosq$length ~ ind))
## Analysis of Variance Table
##
## Response: mosq$length
## Df Sum Sq Mean Sq F value Pr(>F)
## ind 11 2386.35 216.941 166.66 2.329e-11 ***
## Residuals 12 15.62 1.302
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
What happens when we ignore the individual mosquitoes, and just do the ANOVA with the cages as the groups?
anova(aov(length ~ cage, data=mosq))
## Analysis of Variance Table
##
## Response: length
## Df Sum Sq Mean Sq F value Pr(>F)
## cage 2 665.68 332.84 4.0256 0.03312 *
## Residuals 21 1736.30 82.68
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1