15.5 Inference about the Difference of Two Independent Medians

Michael Sullivan

2023-08-30

Base R includes a built-in function to perform a Mann-Whitney test. We will follow Example 1 from Section 15.5. Here, we are testing H_0: M_ILL = M_HEALTHY versus H_1: M_ILL > M_HEALTHY. Begin by entering the data from Table 9.

Ill <- c(640,160,1280,320,80,640,640,160,1280,640,160)
Healthy <- c(10,320,160,160,320,320,10,320,320,80,640)

Now use the wilcox.test function from R. The command paired=F should be included (to indicate an independent sample). The default hypothesis test is a two-tailed test. If the alternative is a right-tailed test, include alternative=‘greater’; if the alternative is a left-tailed test, include alternative=‘less’.

In this example, we have a right-tailed test.

wilcox.test(Ill,Healthy,paired=F,alternative='greater')

## Warning in wilcox.test.default(Ill, Healthy, paired = F, alternative =
## "greater"): cannot compute exact p-value with ties

##
##  Wilcoxon rank sum test with continuity correction
##
## data:  Ill and Healthy
## W = 86, p-value = 0.04657
## alternative hypothesis: true location shift is greater than 0

The P-value is 0.04657.