## Section 5.1: Mann-Whitney Examples ## Example 1: cell <- c(456, 468, 482, 501, 672, 679, 688, 960) radio <- c(426, 436, 444, 449, 626, 626, 642) wilcox.test(cell, radio, alternative="greater", paired=F, exact=T) # The test statistic listed by R subtracts off n*(n+1)/2. # To get the test statistic as our book defines it, type: n <- length(cell) # size of FIRST sample wilcox.test(cell, radio, alternative="greater", paired=F, exact=T)$statistic + n*(n+1)/2 ## Example 2: bidding <- c(199, 210, 228, 232, 245, 246, 246, 249, 255) buyitnow <- c(210, 225, 225, 235, 240, 250, 251) wilcox.test(bidding, buyitnow, alternative="two.sided", paired=F, exact=T) # The test statistic listed by R subtracts off n*(n+1)/2. # To get the test statistic as our book defines it, type: n <- length(bidding) # size of FIRST sample wilcox.test(bidding, buyitnow, alternative="two.sided", paired=F, exact=T)$statistic + n*(n+1)/2 ########## ## CI for E(X) - E(Y) using the Mann-Whitney approach: # Example 1: 90% CI for E(X) - E(Y): round(wilcox.test(cell, radio, conf.int=TRUE, conf.level=0.90, paired=F, exact=T)$conf.int,2) # The sorted pairwise differences Xi - Yj can be obtained by: sort(outer(cell,radio,'-')) # Example 2: 95% CI for E(X) - E(Y): round(wilcox.test(bidding, buyitnow, conf.int=TRUE, conf.level=0.95, paired=F, exact=T)$conf.int,2) # The sorted pairwise differences Xi - Yj can be obtained by: sort(outer(bidding, buyitnow,'-'))