我有一个 2x2 列联表,我想计算里面的对是否显着不同。我制作了一个如下所示的矩阵,名为 raw_matrix
CNS random
Not_H3K4 343 28825
H3K4 11 2014
创建这个矩阵,因此:
raw_matrix = structure(c(343, 11, 28825, 2014),
.Dim = c(2L, 2L), .Dimnames = list(
c("NotH3K", "H3K"), c("CNS", "Random")))
正如我所搜索的那样,像 Barnard's 和 Boschloo 的精确测试这样的无条件精确测试是为此目的最强大的测试。我安装了“Exact”包并尝试使用以下命令进行测试:
exact.test(raw_matrix)
在 64GB 内存和 3.5 GH CPU 的计算机上花了半个多小时,最后它给出了以下错误:
Error: cannot allocate vector of size 42.0 Gb
In addition: Warning messages:
1: In matrix(A[xTbls + 1, ] * B[yTbls + 1, ], ncol = length(int)) :
Reached total allocation of 61417Mb: see help(memory.size)
2: In matrix(A[xTbls + 1, ] * B[yTbls + 1, ], ncol = length(int)) :
Reached total allocation of 61417Mb: see help(memory.size)
3: In matrix(A[xTbls + 1, ] * B[yTbls + 1, ], ncol = length(int)) :
Reached total allocation of 61417Mb: see help(memory.size)
4: In matrix(A[xTbls + 1, ] * B[yTbls + 1, ], ncol = length(int)) :
Reached total allocation of 61417Mb: see help(memory.size)
然后我安装了“Exact2x2”包并使用以下命令进行了测试:
exact2x2(raw_matrix)
这给了我以下结果:
Two-sided Fisher's Exact Test (usual method using minimum likelihood)
data: raw_matrix
p-value = 0.006433
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
1.2028 4.2424
sample estimates:
odds ratio
2.178631
但正如我在“Exact”包教程中所读到的,作为条件精确测试的 Fisher 精确测试并不是那么强大。最后,我使用命令 chisq.test(raw.matrix) 进行了正常的卡方检验,得到的结果与 Fisher 检验的结果不同:
Pearson's Chi-squared test with Yates' continuity correction
data: test_1
X-squared = 6.2045, df = 1, p-value = 0.01274
我是遗传学家,不是统计学专家,如果有人能告诉我这里做这个测试的最佳策略是什么,我很感激