【问题标题】:Wilcox.test returns two different values for the same dataWilcox.test 为相同的数据返回两个不同的值
【发布时间】:2021-05-01 12:39:26
【问题描述】:

我有一个包含两组 A 和 B 的 df。

group <- c(A, A, A, A, A, A, B, B, B, B, B, B, B, B, B, B, B)
measure <- c(3.4, 2.76, 3.37, 2.66, 2.73, 3.91, 9.06, 4.87, 3.4, 3.01, 1.95, 1.88, 1.85, 1.77, 1.77, 0.95, 0.25)
df <- data.frame(group, measure)

如果我说

wilcox.test(measure ~ group, data = df)

我得到 p = 0.06(带有关于关系和确切值的警告)。但是,如果我使用完全相同的数据创建两个向量 A 和 B

 A <- c(3.4, 2.76, 3.37, 2.66, 2.73, 3.91)
 B <- c(9.06, 4.87, 3.4, 3.01, 1.95, 1.88, 1.85, 1.77, 1.77, 0.95, 0.25)

然后说

wilcox.test(A,B, paired = FALSE, alternative = "two.sided")

我得到 p = 0.1908(关于领带的相同错误,我明白了)。这两个值都不是“重要的”,但差异令人不安。我究竟做错了什么?? TIA

【问题讨论】:

  • 创建group &lt;- c(A, A, A, A, A, A, B, B, B, B, B, B, B, B, B, B, B)AB的值是多少
  • B 组的平均值不同,这导致我发现数据输入错误。谢谢!他们现在匹配。

标签: r statistics


【解决方案1】:

无法重现该问题。我认为在第一种情况下,您替换的是变量 A 和 B 而不是标签“A”和“B”

A <- c(3.4, 2.76, 3.37, 2.66, 2.73, 3.91)
B <- c(9.06, 4.87, 3.4, 3.01, 1.95, 1.88, 1.85, 1.77, 1.77, 0.95, 0.25)
wilcox.test(x=A, y=B)

    Wilcoxon rank sum test with continuity correction

data:  A and B
W = 46.5, p-value = 0.1908
alternative hypothesis: true location shift is not equal to 0

Warning message:
In wilcox.test.default(x = A, y = B) :
  cannot compute exact p-value with ties
 

group <- c("A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B")
measure <- c(3.4, 2.76, 3.37, 2.66, 2.73, 3.91, 9.06, 4.87, 3.4, 3.01, 1.95, 1.88, 1.85, 1.77, 1.77, 0.95, 0.25)
df <- data.frame(group, measure)
wilcox.test(measure ~ group, data = df)

    Wilcoxon rank sum test with continuity correction

data:  measure by group
W = 46.5, p-value = 0.1908
alternative hypothesis: true location shift is not equal to 0

Warning message:
In wilcox.test.default(x = c(3.4, 2.76, 3.37, 2.66, 2.73, 3.91),  :
  cannot compute exact p-value with ties

【讨论】:

  • 感谢您的检查 - 问题已解决。实际df中存在数据输入错误。更正后,这两个计算现在给出相同的结果。
猜你喜欢
  • 2021-01-10
  • 2021-03-30
  • 1970-01-01
  • 2018-04-10
  • 2013-02-08
  • 1970-01-01
  • 1970-01-01
  • 2020-10-28
  • 1970-01-01
相关资源
最近更新 更多