【问题标题】:coin package wilcox.test function returns neither error nor resultcoin 包 wilcox.test 函数既不返回错误也不返回结果
【发布时间】:2018-06-08 00:14:46
【问题描述】:

我的mat 数据矩阵是这样的:

V3      V7    
ASD     4.4   
ASD     4.3
control 4.3

我使用以下代码:

mat <- transform(mat, V3 = factor(V3))
wilcox_test(V7 ~ V3, data =mat, distribution = "exact")

但我既没有得到错误也没有得到结果:

当我删除"distribution"时,该功能运行良好:

虽然这个测试显然没有意义,但我希望它与我们工作中的其他测试保持一致(都使用置换测试),所以我希望保留"distribution=exact"。谁能找出问题所在以及如何解决?谢谢!

编辑:我尝试将结果保存并导出为:

pdis=wilcox_test(V7 ~ V3, data =mat, distribution = “exact”)
pdis
summary(pdis)

但我得到“找不到对象 pdis”。我做错了吗?

【问题讨论】:

  • 看起来您没有将 wilcox_test 的结果保存到变量中。如果您正在采购整个脚本,它将运行而不会产生可见的输出。
  • 我担心你截图中的引号,看起来像是“聪明”或“花哨”的引号。当我输入您的数据并运行wilcox_test(V7 ~ V3, data =mat, distribution = "exact") 时,我得到了一个合理的答案Z = 0.70711, p-value = 1 ...
  • 那些看起来像“智能报价”。可能会导致更多错误。

标签: r


【解决方案1】:

coin::wilcox_test 函数将接受带有“精确”参数的分布参数。

library(coin)
mat <- read.table(text="V3      V7    
ASD     4.4   
ASD     4.3
control 4.3",header=TRUE)

mat <- within(mat, V3 = factor(V3))

wilcox_test(V7 ~ V3, data =mat, distribution = "exact")
#------

    Exact Wilcoxon-Mann-Whitney Test

data:  V7 by V3 (ASD, control)
Z = 0.70711, p-value = 1
alternative hypothesis: true mu is not equal to 0

不清楚您的问题可能是什么:

>  pdis <- wilcox_test(V7 ~ V3, data =mat, distribution = "exact")
> summary(pdis)
                Length                  Class                   Mode 
                     1 ScalarIndependenceTest                     S4 

也许您确实有一个 R data.matrix,但在这种情况下,您不能有一个因子列。 R 矩阵不允许属性,并且因子被强制转换为整数。

【讨论】:

    猜你喜欢
    • 2018-07-01
    • 2015-10-05
    • 2021-09-24
    • 1970-01-01
    • 2011-09-30
    • 2023-03-02
    • 2011-12-27
    • 1970-01-01
    • 2018-05-04
    相关资源
    最近更新 更多