gpt4 book ai didi

r - Mann-Whitney U 的 p 值为 1 - 伪影?

转载 作者:行者123 更新时间:2023-12-02 19:30:21 24 4
gpt4 key购买 nike

我通过 RStudio 1.2.5042 在 R 3.6.3 中使用 rstatix 库,并且在运行两个样本 Wilcoxon 又名 Mann-Whitney U 测试时得到了不可能的 p 值 1 .

我的第一直觉是这是一个浮点精度问题,实际值大约是 0.999999,但我来这里是为了在一个未公开的联邦研究机构对此大惊小怪之前确认这一点。

这是我的代码:

wilcox_test(data,
DV ~ Group,
paired = F,
exact = T,
alternative = "two.sided",
conf.level = 0.95,
detailed = T)

Link to .csv formatted data

数据当然是匿名的。此链接将在 1 周后过期。

交叉发布以保持一致性:

https://stats.stackexchange.com/questions/467572/p-value-of-1-for-mann-whitney-u-artifact-of-r

最佳答案

稍微挖掘一下就会发现,rstatix::wilcox_test() 正在抑制有关关系与其实现中的精确性不兼容的警告。如果您运行普通的旧 stats::wilcox.test() (rstatix 最终会调用它),就会发生这种情况:

w <- wilcox.test(DV~Group,data=dat)

Warning message: In wilcox.test.default(x = c(5L, 0L, 0L, 3L, 0L, 1L, 3L, 4L, 0L, : cannot compute exact p-value with ties

您可以看到here rstatix 正在抑制此警告。

为了再次检查,我研究了 wilcox.test 的内部内容:近似检验的 Z 统计量公式为

STATISTIC-n.x*n.y/2-CORRECTION

(请参阅 Wikipedia:但没有提及连续性校正)。

在本例中,W 统计量为 209.5,n.x*n.y/2 为 209,连续性校正为 0.5 - 因此您得到的 Z 统计量恰好为零,因此 pnorm(z) 为 0.5,双尾检验统计量恰好 1。

如果您想准确地处理关系:

coin::wilcox_test(DV~factor(Group), data=dat, distribution="exact")
## Exact Wilcoxon-Mann-Whitney Test
## data: DV by factor(Group) (Control, Treatment)
## Z = 0.013327, p-value = 0.9954
## alternative hypothesis: true mu is not equal to 0

关于r - Mann-Whitney U 的 p 值为 1 - 伪影?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61916001/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com