1

我有一个 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

我是遗传学家,不是统计学专家,如果有人能告诉我这里做这个测试的最佳策略是什么,我很感激

4

1 回答 1

1

已经很多了,但是我在这里结束了对这个主题的研究,所以我想我可以分享我的发现。

您显示的表格看起来是无条件的(意味着您事先不知道行或列的总和),这很好,但它要求进行无条件测试。这是我们在构建列联表之前应该问的唯一问题:从实验设计中知道行或列的总和?.

费舍尔的检验是完全有条件的,在这种情况下可能会被反对(除了“女士品尝茶”实验之外,几乎所有的情况下都是如此)。

Pearsons 的情况似乎很好(主要关注的是单元格中的小数字,例如 <5,所以应该没问题),即使它几乎从来不是最佳选择,它仍然被广泛使用。

确切的无条件测试会更好(好奇到底好多少),但看起来数字大到足以引发计算问题,所以 Pearson 就是这样。

于 2018-12-30T21:51:20.200 回答