来自 R 中 wilcox.test 的意外 [可能不正确] W 检验统计量

问题描述

示例数据、调用和输出如下。

wilcox.test() 输出正在做一些我意想不到的事情:它没有打印 W 测试统计量的最小值。尽管 p 值和位置估计值没有变化(除了位置值的符号,正如预期的那样),打印的 W 统计量会根据设置为二进制变量参考的级别而变化。实施此选择是否有原因?

此外,这两个 W 值似乎并不相加。使用 n1 = 100 和 n2 = 159 的两个组,W1 和 W2 的值应为 n1 x n2 (= 15,900)。我在下面发布的示例得到 W1 = 4823.5 和 W2 = 11076。W1 + w2 = 15,899.5。类似地,位置估计值也略有偏差(2.999952 而不是 3)。对于这些小差异有什么建议,我应该将 4823.5 的可能错误值更正为 4824 吗?

编辑: 11076 是问题所在。当我将 wilcox.test 的输出存储在一个对象中并随后查看时,W 的实际值为 11076.5。一个不同的问题,但由于其自身的原因,这仍然是有问题的。

注意包含一个二元变量 (DSMInsomnia) 和一个数字变量 (rMEQ) 的示例数据:“是”的组大小为 100,中位数为数值变量的值为 11,而“否”组的 159 个观测值的中值为 14。

数据:

df <- structure(list(rMEQ = c(18,10,17,11,14,12,13,15,9,16,18,19,20,6,8,23,21,5,4,7,22,7),DSMInsomnia = structure(c(1L,1L,2L,2L),.Label = c("No","Yes"),class = "factor")),row.names = c(NA,-259L),class = "data.frame")

DSMInsomnia 变量的参考电平设置为“是”并运行 wilcox.test()

df$DSMInsomnia <- relevel(df$DSMInsomnia,ref = "Yes")
wilcox.test(data = df,rMEQ ~ DSMInsomnia,paired = FALSE,conf.int = T,exact = T)

输出:

cannot compute exact p-value with tiescannot compute exact confidence intervals with ties
    Wilcoxon rank sum test with continuity correction

data:  as.numeric(rMEQ) by DSMInsomnia
W = 4823.5,p-value = 9.141e-08
alternative hypothesis: true location shift is not equal to 0
95 percent confidence interval:
 -3.999959 -1.999953
sample estimates:
difference in location 
             -2.999952

DSMInsomnia 变量的参考电平设置为“No”并运行 wilcox.test()

df$DSMInsomnia <- relevel(df$DSMInsomnia,ref = "No")
wilcox.test(data = df,exact = T)

输出:

cannot compute exact p-value with tiescannot compute exact confidence intervals with ties
    Wilcoxon rank sum test with continuity correction

data:  as.numeric(rMEQ) by DSMInsomnia
W = 11076,p-value = 9.141e-08
alternative hypothesis: true location shift is not equal to 0
95 percent confidence interval:
 1.999953 3.999959
sample estimates:
difference in location 
              2.999952

附言原谅问题的错误标签,但我没有制作更具体的新标签的声誉。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...