Location Inference for Single Samples

Mar 27, 2019
Jan 27, 2021 19:21 UTC
The Wilcoxin signed rank test explained.

Previously we’ve used the sign test to look at the median (a measure of location) survival time with a censored data point. The original observations were transformed into “successes” and “failures” and a lot of information was thrown out.

For location inference, a basic one-sample procedure is the Wilcoxon Signed-Rank test. It’s used to test whether a sample comes from a population with a specified mean or median.

Wilcoxon signed-rank test

Suppose $n$ observations $x_1, x_2, \cdots, x_n$, are a sample from a symmetric continuous distribution with unknown median, $\theta$. We want to test:

$$H_0: \theta = \theta_0 \text{ vs. } H_1: \theta \neq \theta_0$$

The assumption of symmetry implies that under $H_0$:

\begin{aligned} d_i = x_i - \theta_0 && i = 1, 2, \cdots, n \end{aligned}

• Each $d_i = x_i - \theta_0$ is equally likely to be positive or negative (i.e. each $x_i$ is equally likely to be above or below $\theta_0$ under $H_0$ - logic for sign test).
• The magnitude $|d_i|$ of any size is equally likely to be positive or negative.

A symmetric population distribution has a mean that coincides with the median. In those circumstances the test may also be formulated in terms of means. The test procedure is simple:

1. Calculate the discrepancies of each observation from $\theta_0$, the median hypothesized under $H_0$.
2. Order these magnitudes (i.e. in absolute value) from smallest ($\text{rank} = 1$) to largest ($\text{rank} = n$).
3. Assign a $+$ sign to ranks corresponding to $d_i > 0$, and a $-$ sign to ranks corresponding to $d_i < 0$.

From here, we can define a few different test statistics. We denote by $S_+$the the sum of positive ranks, and by $S_-$ the sum of ranks associated with negative deviations. These two are equivalent to each other because the total sum of ranks in sample of size $n$ is fixed: $1 + 2 + \cdots + n = S_+ + S_-$. We may use any of the statistics $S_+, S_-$, or a third statistics $S_d = |S_+ - S_-|$ as a test statistic. All three have the same information about the plausibility of $H_0$. Under $H_0$, we’d expect $S_+$ and $S_-$ to be roughly equal, and likewise $S_d$ should be close to $0$. Intermediate values of $S_+$ or $S_-$ are more supportive of $H_0$.

We can use the permutation test approach to get the exact distribution for any of the three test statistics. We look at all the possible allocations of $+/-$ signs to the ranks $1,2, \cdots, n$. Let’s take a look at the following example.

Heart rate example

Heart rate (beats per minute) when standing was recorded for seven people. Assume a symmetric distribution for heart rate in the population. Continuity is questionable as heart rate is an integer, but we’re okay if there are no ties, which is usually why we assume continuity.

The observed data is:

$$73, 82, 87, 68, 106, 60, 97$$

Suppose we want to test

\begin{aligned} &H_0: \theta = 70 \\ \text{vs. } &H_1: \theta > 70 && \text{one-sided alternative} \end{aligned}

First, compute $|d_i| = |x_i - \theta_0| = |x_i - 70|$, $i = 1, \cdots, 7$:

Magnitude $|d_i|$312172361027
Rank245-17-36

Note now we added a minus sign to the ranks of the observations that were smaller than 70. Now we can calculate the test statistics:

\begin{aligned} \Rightarrow S_+ &= 2 + 4 + 5 + 7 + 6 = 24 \\ S_- &= 1 + 3 = 4 \\ S_d &= |S_+ - S_-| = 20 \end{aligned}

Sanity check: $1 + \cdots + 7 = 28 = S_+ + S_-$.

Under $H_0$ ($\theta = 70$), we’d expect $S_+ \approx S_-$ and $S_d \approx 0$. Under $H_1$ ($\theta > 70$), we’d expect $S_+ > S_-$ and $S_d$ to be larger. Here we observe $S_+$ to be appreciably larger than $S_-$, which is in support of $H_1$.

For the permutation test, we need to build the permutation distribution. Note that $S_+$ can take values from 0 (when all ranks are negative $\Rightarrow$ all observations are less than $\theta_0$) up to 28 (all ranks are positive). There are $2^7 = 128$ ways of allocating $+/-$ signs to the ranks. All of them are equally likely under $H_0$. Below we have a few possible configs:

1234567$S_+$$S_-$$S_d$
-------02828
+------12726

Summary

1. The sign test, unlike the Wilcoxon signed rank test, does not require symmetry of the underlying distribution. When the data come from a skewed distribution (e.g. income), both the t-test and the Wilcoxon may be inappropriate in the sense that they may not give us valid inference. This depends in part on how skewed the population distribution is. The sign test will still be valid. Confidence intervals based on the t-test / Wilcoxon may also be misleading. Those based on the sign test (and Binomial distribution) will still be fine. In other situations, all three will lead to similar conclusions.
2. A suggestion: try different analyses and see if your conclusions are consistent.
3. When the symmetry assumption is violated, the sign test may have higher efficiency - higher power in tests and shorter confidence intervals for a given confidence level. We can compare the asymptotic relative efficiency of the sign test, Wilcoxon and t-test:
• ARE of the Wilcoxon compared to the t-test is at least 0.864, and can go up to infinity under some circumstances.
• The Wilcoxon is never “too bad” and can be very good.
• When the data are actually normally distributed (the situation where the t-test is optimal), the ARE of Wilcoxon is 0.955, so very little loss here.

Up to this point, we’ve been talking about location inference - questions about the mean or median of the population distribution, but we can do a lot more. One particularly useful application is studying whether our data are consistent with having been drawn from some specified distribution.

1. For each distribution, there’s a series of functions in R to get the density dsignrank, distribution function psignrank, quantile function qsignrank and random numbers rsignrank. ↩︎

2. Hodges Jr, J. L., & Lehmann, E. L. (1963). Estimates of location based on rank tests. The Annals of Mathematical Statistics, 598-611. ↩︎

3. Streitberg, B., & Röhmel, J. (1984). Exact nonparametrics in APL. ACM SIGAPL APL Quote Quad, 14(4), 313-325. ↩︎

Related Posts
 May 08 Modern Nonparametric Regression 8 min read May 06 Categorical Data 17 min read May 06 Density Estimation 6 min read May 06 Bootstrap 11 min read May 05 Correlation and Concordance 9 min read