One-way ANOVA
> install.packages("multcomp")
> library(multcomp)
> attach(cholesterol)
条件:因为 one-way ANOVA 的因变量需要满足正态分布,并且各组等方差
In a one-way ANOVA, the dependent variable is assumed to be normally distributed, and have equal variance in each group
Step-1:用QQPlot检查是否符合正态分布条件
use a Q-Q plot to assess the normality assumption
> install.packages("car")
> library(car)
> qqPlot(lm(response~trt,data=cholesterol),simulate=TRUE,main="Q-Q Plot",labels=FALSE)
#data fall within the 95 percent confidence envelope,
#suggesting that the normality assumption has been met fairly well
Step-2: 用 ANOVA
> fit <- aov(response~trt)
> summary(fit)
Df Sum Sq Mean Sq F value Pr(>F)
trt 4 1351.4 337.8 32.43 9.82e-13 ***
Residuals 45 468.8 10.4
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
结论:
The ANOVA F test for treatment (trt) is significant (p < .0001), providing evidence that the