如何从r中的wilcox检验统计量中获得p值?

yeotifhr  于 2023-01-18  发布在  其他
关注(0)|答案(1)|浏览(173)

我有一个实验,我在r中多次调用wilcox.test,并收集统计输出。我计算这些统计的平均值,然后我想将其转换为p值。我应该在r中调用什么函数来获取wilcox test的统计作为输入,并将p值作为输出?

wilcox.statistics <- 692304.08
wilcox.pvalue <- whatFunction(wilcox.statistics) ???
brvekthn

brvekthn1#

我不知道你用什么函数来得到统计数据,但是如果你运行wilcox.test

x <- wilcox.test(rnorm(10), rnorm(10, 2), conf.int = TRUE) 
str(x)
    • 输出:**
List of 9
 $ statistic  : Named num 8
  ..- attr(*, "names")= chr "W"
 $ parameter  : NULL
 $ p.value    : num 0.000725
 $ null.value : Named num 0
  ..- attr(*, "names")= chr "location shift"
 $ alternative: chr "two.sided"
 $ method     : chr "Wilcoxon rank sum exact test"
 $ data.name  : chr "rnorm(10) and rnorm(10, 2)"
 $ conf.int   : num [1:2] -2.75 -1.19
  ..- attr(*, "conf.level")= num 0.95
 $ estimate   : Named num -1.93
  ..- attr(*, "names")= chr "difference in location"
 - attr(*, "class")= chr "htest"

您可以在输出列表中获得统计数据和p. value,根据您的目标,您可以提取它们,甚至使用类似broom的包:

broom::tidy(x)
    • 输出:**
# A tibble: 1 x 7
  estimate statistic  p.value conf.low conf.high method                       alternative
     <dbl>     <dbl>    <dbl>    <dbl>     <dbl> <chr>                        <chr>      
1    -1.93         8 0.000725    -2.75     -1.19 Wilcoxon rank sum exact test two.sided

相关问题