我有一个2x10的应急方案。不幸的是,6个细胞的期望值小于5,因此我不能使用Pearson检验。
我试着在R (fisher.test(),如果我理解的话自动做了一个Freeman-Halton扩展)中使用Fisher's测试,但是我不认为我的计算机能够处理计算量。
这就是我会遇到的错误:
Error in fisher.test(x$size, y$gender, workspace = 2e+08) :
FEXACT error 7(location). LDSTP=18716400 is too small for this problem,
(pastp=328.023, ipn_0:=ipoin[itp=120337]=176553, stp[ipn_0]=318.699).
Increase workspace or consider using 'simulate.p.value=TRUE'尝试将工作区增加到2e9,并得到以下错误:
Error: cannot allocate vector of size 7.5 Gb用Yates的修正协议来检验这个问题,卡方检验会吗?即使如此,我似乎也不能强迫R对我的计算做Yates修正,因为某种原因-- chisq.test(x$size, y$gender, correct=T)。相反,与correct=F,工作。
有什么建议吗?或者我可以用的替代测试?
谢谢!
发布于 2020-03-21 16:46:18
让我们来看看这个例子:
set.seed(111)
value = rnbinom(1000,mu=69,size=1)
size = cut(value,10)
gender = rep(c("M","F"),each=500)
table(gender,size)
gender (-0.466,46.6] (46.6,93.2] (93.2,140] (140,186] (186,233] (233,280]
F 244 107 67 42 17 11
M 255 127 64 28 11 8
size
gender (280,326] (326,373] (373,419] (419,466]
F 7 4 0 1
M 4 2 1 0
fisher.test(gender, size)
Error in fisher.test(gender, size) :
FEXACT error 7(location). LDSTP=18480 is too small for this problem,
(pastp=81.1067, ipn_0:=ipoin[itp=68]=79, stp[ipn_0]=80.6036).
Increase workspace or consider using 'simulate.p.value=TRUE'就像你说的,chisq测试有修正:
chisq.test(gender,size)$p.value
[1] 0.3452619
chisq.test(gender,size,correct=TRUE)$p.value
[1] 0.3452619有一个很好的理由:
校正:在计算2×2表的测试统计量时是否应用连续性校正的逻辑。
您可以使用simulate.p.value = TRUE,就像Dave2e指出的那样,在本例中,这或多或少是可以的,因为我在null下进行了模拟,其中两个组之间没有区别:
Fisher's Exact Test for Count Data with simulated p-value (based on
2000 replicates)
data: gender and size
p-value = 0.3393
alternative hypothesis: two.sided它基本上是一个模拟分布的chisquare测试:
library(coin)
chisq_test(table(gender,size),distribution = approximate(nresample = 10000))
Approximative Pearson Chi-Squared Test
data: size by gender (F, M)
chi-squared = 10.065, p-value = 0.3263如果您的类别是有序的,您可以尝试线性逐个线性关联,检查更多的这里。
https://stackoverflow.com/questions/60785035
复制相似问题