<- data.frame(diet1 = c(90, 95, 100),
dtf diet2 = c(120, 125, 130),
diet3 = c(125, 130, 135))
<- stack(dtf)
dtf2 names(dtf2) <- c("wg", "diet")
<- aov(wg ~ diet, data = dtf2)
wg_aov summary(wg_aov)
ANOVA Post-hoc tests
Dr. Peng Zhao (✉ peng.zhao@xjtlu.edu.cn)
Department of Health and Environmental Sciences
Xi’an Jiaotong-Liverpool University
1 Learning objectives
- What is a post-hoc test and why we need it.
- Carry out step-by-step post-hoc tests, including the Fisher’s Lease Significant Difference test and the Bonferroni t-test, for ANOVA.
2 Post-hoc tests
Post-hoc
- Latin, “after this”
- Applied only after the ANOVA that yields a significant difference.
Example: Rats on diets
A biologist studies the weight gain of male lab rats on diets over a 4-week period. Three different diets are applied.
Which group(s) is/are different from others? Post-hoc test.
Visually:
library(ggplot2)
ggplot(dtf2) + geom_boxplot(aes(wg, diet))
3 Fisher’s Least Significant Difference (LSD) Test
3.1 Principle
Pair-wise comparisons of all the groups based on the t-test.
(pooled standard deviation; some use Mean Standard Error) critical value at- Degree of freedom:
: total observations : number of factors
Usage
- If
, then the difference of group and group is significant at . - In multiple comparisons (
factors), the number of comparison needed is:
3.2 Example
library(agricolae)
LSD.test(wg_aov, "diet", p.adj = "bonferroni")
Conclusion: At
4 Bonferroni t-test
4.1 Principles
A multiple-comparison post-hoc test, which sets the significance cut off at
Overall chance of making a Type I error:
<- 1:100
m <- 0.05
siglevel 1 - (1 - (siglevel / m)) ^ m
4.2 Example
Example: Rats on diets
<- pairwise.t.test(dtf2$wg, dtf2$diet, pool.sd = FALSE, var.equal = TRUE, p.adj = "none")
diet_pt $p.value < 0.05/m
diet_pt
pairwise.t.test(dtf2$wg, dtf2$diet, pool.sd = FALSE,var.equal = TRUE, p.adj = "bonferroni")
$p.value < 0.05 diet_pt
Conclusion: the same as the LSD test.