library(pander)

Background

Note: the data for this example comes from the original 1945 paper Individual Comparison by Ranking Methods by Frank Wilcoxon.

The percent of flies (bugs) killed from two different concentrations of a certain spray were recorded from 16 different trials, 8 trials per treatment concentration. The experiment hypothesized that the center of the distributions of the percent killed by either concentration were the same. In other words, that both treatments were equally effective. The alternative hypothesis was that the treatments differed in their effectiveness. In short, we wish to know which bug spray is more effective at killing flies (bugs).

Spray Concentration Percent Killed
A 68, 68, 59, 72, 64, 67, 70, 74
B 60, 67, 61, 62, 67, 63, 56, 58

Formally, the null and alternative hypotheses are written as \[ H_0: \text{difference in medians} = 0 \] \[ H_a: \text{difference in medians} \neq 0 \]

The significance level for this study will be set at \[ \alpha = 0.05 \]


Analysis

The side-by-side dotplots below (with boxplots overlaid) suggest that Spray A is more effective than Spray B at killing bugs.

The actual summary values depicted in the plot above are shown in the following table.

bugspray %>%
  group_by(Spray) %>%
  summarise(min = min(Killed), median = median(Killed), mean = mean(Killed), max = max(Killed), sd = sd(Killed), `Number of Trials` = n()) %>%
pander(caption="Summary of Bug Spray Effectiveness")
Summary of Bug Spray Effectiveness
Spray min median mean max sd Number of Trials
A 59 68 67.75 74 4.683 8
B 56 61.5 61.75 67 3.919 8

To determine if it is reasonable to infer that this conclusion is valid in general (for the full population) a Wilcoxon Rank Sum Test will be used. While the two samples are not identically shaped (shown in the boxplots above) they are not different enough to violate the assumption of identical shape and spread that is required by the Rank Sum Test.

Note that since there are ties present in the data, an exact \(p\)-value cannot be computed. An approximation will be used instead. Because of the small sample size, a continuity correction will also be applied. The results of the test are still valid and show sufficient evidence to reject the null hypothesis \((p=0.01771 < \alpha)\).


    Wilcoxon rank sum test with continuity correction

data:  Killed by Spray
W = 55, p-value = 0.01771
alternative hypothesis: true location shift is not equal to 0


Interpretation

Spray A is the more effective spray. Sadly, it still only kills roughly 68% of bugs that make contact with the spray, on average.