本文介绍了方差不等的参数方差分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道R中是否可以做方差不等的方差分析?
I was wondering if there is a way in R to do an ANOVA with unequal variances?
想象下面的例子:
x <- c(10,11,15,8,16,12,20)
y <- c(10,14,18,25,28,30,35)
d <- c(x,y)
f <- as.factor(c(rep("a",7), rep("b",7)))
# Unequal variance:
t.test(x,y)$p.value
t.test(d~f)$p.value
# Equal variance:
t.test(x,y, var.equal=TRUE)$p.value
t.test(d~f, var.equal=TRUE)$p.value
anova(lm(d~f))[[5]]
summary(aov(lm(d~f)))[[1]][5]
summary(lm(d~f))[[4]][8]
从此示例中可以看到,仅在两个组的情况下,在R中执行ANOVA的不同方法始终会导致p值等于通过t.test获得的p值,且方差相等.再次,有没有一种方法可以执行方差不相等的方差分析?
As you can see from this example the different ways of performing an ANOVA in R, in case of two groups only, always result in a p-value identical to the one obtained by a t.test with equal variances. Again, is there a way to perform an ANOVA with unequal variances?
推荐答案
在这种情况下,存在oneway.test()
R> oneway.test(d~f)
One-way analysis of means (not assuming equal variances)
data: d and f
F = 6.631, num df = 1.000, denom df = 8.339, p-value = 0.03179
这篇关于方差不等的参数方差分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!