Reputation: 135
I have an experiment in which I am calling wilcox.test in r for multiple times and gather statistic output. I compute the average of these statistics and then I want to convert it to p-value. What function should I call in r to get statistic of wilcox test as input and take a p-value as output?
wilcox.statistics <- 692304.08
wilcox.pvalue <- whatFunction(wilcox.statistics) ???
Upvotes: 0
Views: 913
Reputation: 8811
I don't know what function you are using to get the statistic, but if you run wilcox.test
x <- wilcox.test(rnorm(10), rnorm(10, 2), conf.int = TRUE)
str(x)
Output:
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"
You can get the statistic and the p.value inside the output list, and depending on your goal you can extract them or even use a package like broom
:
broom::tidy(x)
Output:
# 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
Upvotes: 0