We have seen the definition of a non-parametric hypothesis test. The sign test is an example. We want to test the effectiveness of a drug from 12 observations. The data is the number of hours that the drug relieves pain. The null hypothesis is that the difference between paired medians equals zero.
Case # | Drug A | Drug B |
1 | 2.0 | 3.5 |
2 | 3.6 | 5.7 |
3 | 2.6 | 2.9 |
4 | 2.6 | 2.4 |
5 | 7.3 | 9.9 |
6 | 3.4 | 3.3 |
7 | 14.9 | 16.7 |
8 | 6.6 | 6.0 |
9 | 2.3 | 3.8 |
10 | 2 | 4.0 |
11 | 6.8 | 9.1 |
12 | 8.5 | 20.9 |
The paired differences (Drug B – Drug A) are:
data <- c(1.5, 2.1, 0.3, -0.2, 2.6, -0.1, 1.8, -0.6, 1.5, 2.0, 2.3, 12.4)
Let’s order them in the increasing magnitude.
sort(data)
-0.6 -0.2 -0.1 0.3 1.5 1.5 1.8 2.0 2.1 2.3 2.6 12.4
Under the null hypothesis, we expect half the numbers to be above zero (median) and half below. Suppose r+ observations are > 0 and r− < 0, then under the null hypothesis, r+ and r− follow a binomial distribution with p = 1/2.
In our case, three cases are below zero (r–), and nine are above (r+). So, we estimate the p-value in a binomial test with 9 successes out of 12, but the expected probability is 0.5 under the null hypothesis.
binom.test(9, 12, p = 0.5, alternative = "two.sided")
Exact binomial test
data: 9 and 12
number of successes = 9, number of trials = 12, p-value = 0.146
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.4281415 0.9451394
sample estimates:
probability of success
0.75
Since the p-value is 0.156, we would conclude that there is no evidence of a difference between the two treatments.