In the previous article, we introduced the method of comparing two or more groups of normally distributed data. In this article, we will explain the statistical method used to test the difference of abnormally distributed data , that is, the "rank sum test". This article will focus on the following: independent sample rank sum test, single sample rank sum test and paired sample rank sum test.
Basic Concepts of Rank Sum Test
The rank sum test is a non-parametric test. Non-parametric tests do not consider the parameters of the population and the distribution type of the population, but instead conduct hypothesis tests on the distribution and distribution position of the population represented by the sample.
The basic concept of rank sum test is to first compile the ranking, and then use the ranking to replace the original data for testing. The average ranking of each group is tested based on the ranking. If the average ranking of each group is not equal after testing, it can be inferred that the distribution of the data is different.
This article mainly uses two data for explanation, one is BMI data (Figure 1), and the other is IgA data (Figure 2).

Figure 1 BMI data

Figure 2 IgA data
Independent Samples Rank Sum Test
There are two main methods for the rank sum test of independent samples:
- Wilcoxon rank sum test for comparison between two groups
- Kruskal-Wallis rank sum test for multiple group comparisons
For details, see . The relationship between the two is somewhat similar to that between t-test and analysis of variance.
It should be noted that the comparison between two groups can be done with the Wilcoxon rank sum test or the Kruskal-Wallis rank sum test; the comparison between multiple groups can only be done with the Kruskal-Wallis rank sum test. The operations of the rank sum test for two and multiple independent samples are the same. In order to avoid repeated introduction, this article only introduces the rank sum test for multiple samples as an example.
In the data (Figure 1), suppose we want to compare whether there is a difference in BMI between patients with different cardiac function grades. Therefore, the cardiac function grade is divided into four levels, represented by 1-4 respectively. BMI is an abnormal distribution, so consider the Kruskal-Wallis rank sum test . The analysis process is as follows:
First, click JMP "Analysis" → "Fit Y by X" (as shown in Figure 3 below) to enter the interface for comparing differences between groups.

Figure 3 Independent Sample Rank Sum Test Operation -- Function Table Selection
In this example, BMI is the result and cardiac function grade is the grouping, so in the dialog box, put BMI into "Y, Response" and put "Cardiac function grade" into "X, Factor" (Figure 4).

Figure 4 Independent Samples Rank Sum Test Operation - Variable Selection
After entering the analysis results interface, click the red triangle button above the "Cardiac Function Classification-BMI" single factor analysis, and select " Non-parametric → Wilcoxon Test " in the drop-down menu (Figure 5).

Figure 5 Independent Samples Rank Sum Test Operation -- Method Selection
The output results are shown in Figure 6. The results mainly include two parts:
- The first part is the data description , which gives the number of cases, rank sum, average rank, etc. From the results of the mean score, we can see that patients with heart function grade 4 have the highest BMI.
- The second part is the statistical test results , which gives the results of the Kruskal-Wallis rank sum test. It shows that the BMI difference between patients with different cardiac function grades is statistically significant (Chi-square = 10.4306, P = 0.0152).
Friendly reminder: The statistic given here is chi-square because the result of the Kruskal-Wallis rank sum test obeys the chi-square distribution, not that a chi-square test was performed, so don't get confused.

Figure 6 Independent sample rank sum test operation - test results
Note: If you perform a rank sum test on two groups of samples, you will get two results at the same time: the Wilcoxon rank sum checksum and the Kruskal-Wallis rank sum test. The results of the two tests are consistent. The Kruskal-Wallis rank sum test results show that there is a statistical difference. Usually, we are also interested in which two groups have a difference, which requires a pairwise comparison between the groups.
Next, we click the red triangle button next to the "Cardiac function classification-BMI" single factor analysis, and select "Non-parametric" → "Non-parametric multiple comparisons" → "Perform Steel-Dwass test on all pairs" in the drop-down menu. The operation is shown in Figure 7.

Figure 7 Independent sample rank sum test operation - pairwise comparison operation
The output results are shown in Figure 8. The pairwise comparison results show that the differences between levels 2 and 4 (Z=3.089, P=0.0108) and levels 3 and 4 (Z=3.057, P=0.0120) in the cardiac function classification are statistically significant.

Figure 8 Independent sample rank sum test operation - pairwise comparison test results
The results of this analysis showed that the BMI of patients with different cardiac function grades was statistically different. The results of pairwise comparison showed that the differences between cardiac function grades 2 and 4; 3 and 4 were statistically significant.
One-Sample Rank Sum Test
Based on the data in Figure 1, explore whether the patient's BMI is different from the normal value of healthy people. Assuming that the normal value of BMI is 19 and BMI is abnormally distributed, a single sample rank sum test is performed.
In previous articles, we have explained how to perform a single-sample t-test on normally distributed data. However, in reality, data may not always be normally distributed. When we get data with an abnormal distribution, how should we analyze it?
The first four steps of the one-sample rank sum test are the same as those of the one-sample t test:
① Select "Analysis" → "Distribution" from the JMP menu;
②In the pop-up dialog box, put BMI into "Y, Column";
③ In the result interface, click the red triangle button on the left side of BMI and select "Test Mean" in the drop-down menu;
④In the pop-up dialog box, fill in 19 in the specified hypothesized mean.
For details of the above steps, please refer to " Three Common Methods of Society t Test ".
After completing the above steps, click OK to output the single-sample t test results.
If you want to output the single-sample rank sum test results, continue to check "Wilcoxon signed rank" in the dialog box (Figure 9).

Figure 9 Single sample rank sum test operation - method selection
The results are shown in Figure 10. The results include not only the results of the t-test, but also the results of the rank sum test (the results of the "signed rank" part). The results show that the difference is statistically significant (test statistic = 3114.500, P < 0.0001).

Figure 10 Single sample rank sum test operation - test results
Rank Sum Test for Paired Samples
This example uses the data in Figure 2 to analyze whether there is a difference in IgA before and after chemotherapy. In previous articles, we have explained the steps of paired t test.
The first two steps of the paired rank sum test are the same as those of the paired t test. The operation process is as follows:
① Select the JMP menu "Analysis" → "Professional Modeling" → "Pairing";
② In the pop-up dialog box, in "Y, match response", first enter IgA before chemotherapy, then IgA after chemotherapy.
For details of the above steps, please refer to "Three Common Methods of Society t Test".
After completing the above steps, click the red triangle button next to "Pairing" in the result interface, and select "Wilcoxon Signed Rank" in the drop-down menu to obtain the results of the paired rank test (Figure 11).

Figure 11 Paired rank sum test operation - method selection
The results are shown in Figure 12. There was a statistically significant difference in IgA levels before and after chemotherapy (S=-2523.0, p<0.0001).

Figure 12 Paired rank test operation - test results
in conclusion
Usually, when the data for inter-group comparisons are obviously skewed, we will consider using the rank sum test instead of the t test or analysis of variance (ANOVA). Many people may have some misunderstandings about the rank sum test, and always feel that the rank sum test is like a "spare tire", but in fact the efficiency of the rank sum test is not low.
If the data is normally distributed, the efficiency of the rank sum test is not much different from that of the t test, variance analysis, etc.; if the data is skewed, the efficiency of the rank sum test is much higher than that of the t -test and variance analysis . Therefore, it is recommended that you must consider the distribution of the data in practice and then choose a reasonable and effective analysis method.
Original article: Dry goods | Ideas and analysis of rank sum test and pairwise comparison
Recommended reading:
Thinking context and analysis methods of analysis of variance (ANOVA) and pairwise comparison
Performing Normality and Variance Homogeneity Tests in JMP
Introduction to Design of Experiments (DOE): Classical Screening Design and Full Factorial Design