您可以使用Fligner–Killeen方差齐性检验来检验异方差性。假设您的模型类似于
model<-aov(gain~diet*supplement)
fligner.test(gain~diet*supplement)
Fligner-Killeen test of homogeneity of variances
data: gain by diet by supplement
Fligner-Killeen:med chi-squared = 2.0236, df = 2, p-value = 0.3636
您可以使用bartlett.test(但这更像是对非正态性的测试,而不是对方差相等性的测试)
bartlett.test(gain~diet*supplement)
Bartlett test of homogeneity of variances
data: gain by diet by supplement
Bartlett's K-squared = 2.2513, df = 2, p-value = 0.3244
此外,您可以Levene test
在单向和双向 ANOVA 中执行相等的组方差。Levene 测试的实现可以在包car(链接已修复)、s20x和lawstat 中找到
levene.test(gain~diet*supplement) # car package version
Levene's Test for Homogeneity of Variance
Df F value Pr(>F)
group 11 1.1034 0.3866
36