R wilcoxon rank test


wilcox.test() function performs wilcoxon rank test, which assumes that the means of two unnormally distributed datasets are equal.

wilcox.test(x, ...)
wilcox.test(x, y, alternative = c("two.sided", "less", "greater"),
mu = 0, paired = FALSE, exact = NULL, correct = TRUE,
conf.int=FALSE, conf.level = 0.95, ...)


x,y: Unnormally distributed data sets
ratio: Hypothesized ratio of x/y, default is 1
alternative: alternative hypothesis, including "two.sided","greater","less"
conf.level: confidence level
...

- c(1,5,9,24,56,21,3,7,21,4)
> y <- c(12,15,5,9,9,14,56,22,3,7,32,5)
> wilcox.test(x,y)

Wilcoxon rank sum test with continuity correction
data: x and y
W = 51.5, p-value = 0.5966
alternative hypothesis: true location shift is not equal to 0
Warning message:
In wilcox.test.default(x, y) : cannot compute exact p-value with ties


Since the p-value = 0.5966 is much higher than 0.05, the hypothesis that the two means are equal is accepted.

> y <- c(1233,4356,987,39999,1111,200000)
> wilcox.test(x,y)

Wilcoxon rank sum test with continuity correction
data: x and y
W = 0, p-value = 0.001364
alternative hypothesis: true location shift is not equal to 0
Warning message:
In wilcox.test.default(x, y) : cannot compute exact p-value with ties


p-value = 0.001363 which is much lower than 0.05, rejects the hypothesis.


endmemo.com © 2024  | Terms of Use | Privacy | Home