R 误差-卡方近似值可能不正确
我试着在列联表上做卡方检验R 误差-卡方近似值可能不正确,r,statistics,chi-squared,statistical-test,R,Statistics,Chi Squared,Statistical Test,我试着在列联表上做卡方检验 Satisfied More Or Less Not At All Sat Lower Class 299 787 1876 Working Class 4594 10935 7660 Middle Class 8913 10260 3679 Upper Class
Satisfied More Or Less Not At All Sat
Lower Class 299 787 1876
Working Class 4594 10935 7660
Middle Class 8913 10260 3679
Upper Class 989 420 227
No Class 0 0 0
我使用了代码chisq.test(ct)
,得到了以下错误
Chi-squared approximation may be incorrect
Pearson's Chi-squared test
data: ct
X-squared = NaN, df = 8, p-value = NA
当我查找错误时,我找到了要求刺激p值chisq.test(ct,simulate.p.value=TRUE)
我还是会出错
cannot compute simulated p-value with zero marginals Chi-squared approximation may be incorrect
Pearson's Chi-squared test
data: ct
X-squared = NaN, df = 8, p-value = NA
我想知道哪里出了问题,是否可以对数据执行其他测试。为什么有一个没有元素的无类?这似乎没有必要,您是否尝试过删除它?它告诉您问题是零边缘(即“无类”值)。在我看来,这些似乎是为了表示缺少的类值。既然你没有这些,为什么不删除“无类”的边缘?
chisq.test(ct[-5L,])
在我的笔记本电脑上工作。chisq.test(ct[-5L,])
也适用于我。你能解释一下ct[-5L]的作用吗?无论如何谢谢你@ekoam@Roland已经向你解释了背后的原因。卡方检验不能使用零边缘。该代码仅仅意味着在删除最后一行后运行chisq.test
。