双向方差分析的同方差检验
我一直在使用 var.test
和 bartlett.test
来检查基本的方差分析假设,其中包括同质性(同质性、方差相等)。对于单向方差分析,程序非常简单:
bartlett.test(x ~ g) # where x is numeric, and g is a factor
var.test(x ~ g)
但是,对于 2x2 表,即双向方差分析,我想做这样的事情:
bartlett.test(x ~ c(g1, g2)) # or with list; see latter:
var.test(x ~ list(g1, g2))
当然,可以使用图形程序检查方差分析假设,但是“算术选项”?这是可以管理的吗?如何在双向方差分析中检验同方差性?
I've been using var.test
and bartlett.test
to check basic ANOVA assumptions, among others, homoscedascity (homogeniety, equality of variances). Procedure is quite simple for One-Way ANOVA:
bartlett.test(x ~ g) # where x is numeric, and g is a factor
var.test(x ~ g)
But, for 2x2 tables, i.e. Two-Way ANOVA's, I want to do something like this:
bartlett.test(x ~ c(g1, g2)) # or with list; see latter:
var.test(x ~ list(g1, g2))
Of course, ANOVA assumptions can be checked with graphical procedures, but what about "an arithmetic option"? Is that, at all, manageable? How do you test homoscedascity in Two-Way ANOVA?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设检验是评估模型假设有效性的错误工具。如果样本量很小,即使方差差异很大,您也没有能力检测任何方差差异。如果你有很大的样本量,你就有能力检测到最微小的等方差偏差,所以你几乎总是会拒绝零值。模拟研究表明,模型假设的初步测试会导致不可靠的 I 类错误。
查看所有单元格的残差是一个很好的指标,或者如果您的数据正常,您可以使用具有/不具有相等方差的 AIC 或 BIC 作为选择程序。
如果您认为方差不等,请放弃这样的假设:
使用稳健方法(异方差一致协方差矩阵)不会失去太多功效,因此如果有疑问,请采用稳健方法。
Hypothesis testing is the wrong tool to use to asses the validity of model assumptions. If the sample size is small, you have no power to detect any variance differences, even if the variance differences are large. If you have a large sample size you have power to detect even the most trivial deviations from equal variance, so you will almost always reject the null. Simulation studies have shown that preliminary testing of model assumption leads to unreliable type I errors.
Looking at the residuals across all cells is a good indicator, or if your data are normal, you can use the AIC or BIC with/without equal variances as a selection procedure.
If you think there are unequal variances, drop the assumption with something like:
You don't loose much power with the robust method (hetroscedastic consistent covariance matrices), so if in doubt go robust.
您可以使用 Fligner–Killeen 测试< /a> 方差的同质性。假设您的模型类似于
您可以使用 bartlett。测试(但这更多的是对非正态性的测试,而不是方差相等的测试)
此外,您可以对单向和双向的相等组方差执行
Levene测试
方差分析。 Levene 测试的实现可以在包 car 中找到(链接已修复),s20x 和 < a href="http://finzi.psych.upenn.edu/R/library/lawstat/html/levene.test.html" rel="nofollow noreferrer">lawstatYou can test for heteroscedasticity using the Fligner–Killeen test of homogeneity of variances. Supposing your model is something like
You could have used bartlett.test (but this is more a test of non-normality than of equality of variances)
Moreover, you could perform the
Levene test
for equal group variances in both one-way and two-way ANOVA. Implementations of Levene's test can be found in packages car (link fixed), s20x and lawstat对于
bartlett.test
var.test
不适用,因为它仅在有两个组时才有效。For
bartlett.test
var.test
is not applicable as it works only when there are two groups.