How can I perform a Wilcoxon Signed Rank Test in Stata?

The Wilcoxon Signed Rank Test is a non-parametric statistical test used to determine if there is a significant difference between two paired samples. In Stata, this test can be performed by using the “wilcoxon” command, which calculates the test statistic and p-value for the paired sample data. This allows researchers to assess the significance of any differences between the two samples and make informed conclusions about their relationship. The “wilcoxon” command also provides options for conducting one-tailed or two-tailed tests, as well as for adjusting for ties in the data. Overall, the Wilcoxon Signed Rank Test in Stata provides a reliable and efficient way to analyze paired sample data and make meaningful statistical inferences.

Perform a Wilcoxon Signed Rank Test in Stata


The  is the non-parametric version of . It is used to test whether or not there is a significant difference between two population means when the distribution of the differences between the two samples cannot be assumed to be normal.

This tutorial explains how to conduct a Wilcoxon Signed Rank Test in Stata.

How to Perform a Wilcoxon Signed Rank Test in Stata

For this example we will use the fuel dataset, which contains the mpg of 12 cars both before and after they received a certain fuel treatment.

Use the following steps to perform a Wilcoxon Signed Rank Test to determine if there is a difference in the mean mpg between the two groups.

Step 1: Load and view the data.

First, load the dataset by typing the following command into the Command box:

use http://www.stata-press.com/data/r13/fuel

View the raw data by using the following command:

list

The first column, mpg1, shows the mpg of each car before the fuel treatment while the second column, mpg2, shows the mpg of each car after the fuel treatment.

Step 2: Perform the Wilcoxon Signed Rank Test.

We can use the signrank command to perform a Wilcoxon Signed Rank Test in Stata:

signrank mpg1 = mpg2

Wilcoxon Signed Rank Test output in Stata

Here is how to interpret the output:

Hypothesis test: Near the bottom of the output we can see that the null hypothesis we tested was Ho: mpg1 = mpg2. The z test statistic turned out to be -1.973 and the corresponding p-value was 0.0485. Since this value is less than 0.05, we reject the null hypothesis and conclude that there is a statistically significant difference between the mean mpg of the two groups.

Step 3: Report the results.

Lastly, we want to report the results of the Wilcoxon Signed Rank Test. Here is an example of how to do so:

A Wilcoxon Signed Rank Test was performed to determine if there was a statistically significant difference in the mean mpg before and after a car received fuel treatment. A total of 12 cars were used in the analysis.

The test revealed that there was a statistically significant difference in mean mpg between the two groups (z = -1.973, p = 0.0485).

These results indicate that the fuel treatment had a significant effect on the mpg of a car.

x