Learn How to Perform a Kruskal-Wallis Test in SPSS: A Step-by-Step Tutorial


The Kruskal-Wallis Test is a fundamental statistical procedure used in research to determine whether there are statistically significant differences between the medians of three or more independent groups. It serves as the powerful non-parametric alternative to the one-way ANOVA (Analysis of Variance). This test is particularly valuable when the assumptions required for ANOVA—specifically, the assumption of normality and homogeneity of variances—are violated, or when dealing with data measured on an ordinal scale.

When conducting analysis on data that does not meet the strict requirements of parametric tests, the Kruskal-Wallis H test, often referred to as Kruskal-Wallis one-way ANOVA by ranks, provides a robust method for comparing group distributions. Instead of comparing mean values, which are highly susceptible to outliers in non-normal distributions, this test converts the raw data values into ranks and then compares the mean ranks of the different groups. A statistically significant result indicates that at least one group median is different from the others, prompting the need for subsequent post-hoc analysis to identify which specific pairs of groups differ.

This comprehensive tutorial will guide you through the process of executing and interpreting the Kruskal-Wallis Test using IBM SPSS Statistics, a widely utilized software package in social science and medical research. By following these detailed steps, you will be equipped to handle complex data comparisons where parametric assumptions cannot be met, ensuring the validity and reliability of your statistical conclusions.

The Kruskal-Wallis Test: Purpose and Assumptions

Understanding the context for choosing the Kruskal-Wallis test is essential for proper statistical application. The test is specifically designed for situations involving a single categorical independent variable (with three or more levels or groups) and a continuous or ordinal dependent variable. Its primary purpose is to test the null hypothesis that all samples originate from the same distribution, meaning their population medians are equal.

Unlike ANOVA, which relies heavily on the distribution of the data being approximately normal, the Kruskal-Wallis test makes minimal assumptions about the shape of the population distributions. However, it does still require two key conditions to be met for reliable interpretation. First, the samples must be independent, meaning the observations within one group do not influence the observations in any other group. Second, if you intend to interpret a significant result as a difference in medians, you must assume that the shape of the distribution of scores is similar across all groups, even if the distributions themselves are not normal. If the shapes differ significantly, a rejection of the null hypothesis simply suggests a difference in distributions generally, rather than specifically in the medians.

Choosing the Kruskal-Wallis test over ANOVA is a strategic decision made when preliminary data exploration reveals issues such as severe skewness, presence of influential outliers that cannot be justified for removal, or when the data is intrinsically ordinal (e.g., pain ratings, satisfaction scores). By focusing on the ranks of the data rather than the raw scores, the test minimizes the distorting effect of extreme values, providing a more robust comparison of central tendency across multiple groups.

Example Scenario: Evaluating Drug Efficacy

To illustrate the application of this test, consider a common scenario in clinical research. A medical researcher aims to evaluate the comparative effectiveness of three distinct pharmaceutical treatments (Drug 1, Drug 2, and Drug 3) on alleviating chronic knee pain. This study is designed as a randomized control trial to ensure group independence.

The researcher recruits 30 adult participants who all report comparable levels of chronic knee pain severity at baseline. These participants are then randomly assigned into three equal groups of 10, with each group receiving one of the three drugs. This randomization is crucial for maintaining the assumption of independent samples. The independent variable is the type of drug administered, which has three distinct levels (Drug 1, Drug 2, Drug 3).

After a standardized treatment period of one month, the researcher collects the dependent variable data. Each individual is asked to quantify their current knee pain using a numerical rating scale ranging from 1 to 100, where a score of 1 signifies no pain and a score of 100 indicates the most severe, unbearable pain. Since pain perception scores are often ordinal in nature and may not follow a perfect normal distribution, the Kruskal-Wallis test is the appropriate statistical tool to determine if there is a statistically significant difference in the reported pain medians among the three treatment groups. The data collected from all 30 individuals is structured in the SPSS data view as follows:

We will now use these data to perform the Kruskal-Wallis Test in SPSS, following a step-by-step procedure to test the null hypothesis that all three drugs result in the same level of post-treatment knee pain (i.e., the population medians are equal).

Step 1: Accessing the Kruskal-Wallis Test Dialog in SPSS

Executing the Kruskal-Wallis Test in SPSS requires navigating through the specialized menu options reserved for non-parametric procedures. This ensures that the appropriate rank-based calculations are performed on the data, bypassing the standard parametric tests.

The process begins by initiating the analysis sequence. Click on the Analyze tab located in the main menu bar of SPSS. From the dropdown menu that appears, hover over Nonparametric Tests. Since the Kruskal-Wallis test is one of the classic statistical methods, it is typically located within the legacy features of the software. Proceed by selecting Legacy Dialogs, and finally, click on K Independent Samples. This selection is crucial as the ‘K’ stands for three or more independent groups being compared, which perfectly matches our drug efficacy example.

The exact navigational path to perform the Kruskal-Wallis test is: Analyze > Nonparametric Tests > Legacy Dialogs > K Independent Samples.

This sequence opens the primary dialog box for running multi-group non-parametric comparisons. Once this window is open, the next critical step involves correctly assigning the dependent and independent variables and defining the range of the grouping variable so that SPSS knows exactly which groups to compare.

Step 2: Defining Variables and Test Parameters

Once the Tests for Several Independent Samples dialog box appears, you must specify the variables that will be used for the analysis. The dependent variable, which is the score we are comparing across groups, must be moved into the Test Variable List box. In our example, this is the variable named pain.

Next, the independent variable, which defines the different groups, must be moved into the Grouping Variable box. In this study, the independent variable is drug (coded 1 for Drug 1, 2 for Drug 2, and 3 for Drug 3). After moving the grouping variable, the Define Range button will become active. Clicking this button is essential because SPSS needs explicit instructions regarding the minimum and maximum values (codes) that represent the groups you wish to include in the analysis.

In the Define Range sub-dialog box, set the Minimum value to 1 and the Maximum value to 3, corresponding to our three treatment groups (Drug 1, Drug 2, and Drug 3). Click Continue to save the range definition. Finally, ensure that the checkbox next to Kruskal-Wallis H is selected under the Test Type options. This confirms that you are running the correct non-parametric procedure. After confirming the variables, the range, and the test type, click OK to execute the analysis.

Kruskal-Wallis test options in SPSS

Upon clicking OK, SPSS processes the data by ranking all 30 pain scores across the entire dataset, calculates the mean rank for each drug group, and then computes the Kruskal-Wallis H statistic based on these ranks. The output will immediately be displayed in the SPSS Output Viewer.

Step 3: Interpreting the Kruskal-Wallis Test Results

The output generated by SPSS for the Kruskal-Wallis test typically consists of two main tables: the Ranks table and the Test Statistics table. Both tables provide crucial information necessary for drawing a statistical conclusion about the null hypothesis.

The first table, the Ranks table, summarizes the data by displaying the Mean Rank for the pain scores within each of the three drug groups. This table provides the initial descriptive evidence of potential differences. If the null hypothesis (that the population medians are equal) is true, we would expect the mean ranks across all groups to be roughly similar. A large disparity in mean ranks suggests that the distributions of pain scores differ significantly based on the treatment received.

The second table, the Test Statistics table, contains the quantitative results used for hypothesis testing. This table is the most critical part of the output:

Output of Kruskal-Wallis Test in SPSS

The key elements within the Test Statistics table are:

  • Kruskal-Wallis H: This value represents the calculated test statistic, which is an approximation of the Chi-squared test statistic ($X^2$). In our example, the Kruskal-Wallis H value is 3.097. This statistic measures the magnitude of the differences observed in the mean ranks across the groups. A larger H value suggests greater differences between the group distributions.
  • df (Degrees of Freedom): The degrees of freedom are calculated as the number of groups minus one ($k-1$). Since we have three groups (Drug 1, Drug 2, Drug 3), the degrees of freedom are $3 – 1 = 2$.
  • Asymp. Sig. (Asymptotic Significance): This value represents the two-sided p-value associated with the calculated H statistic (3.097) and the corresponding degrees of freedom (2). The Asymp. Sig. is the probability of observing the data (or data more extreme) if the null hypothesis were true.

Step 4: Drawing a Statistical Conclusion

The final step involves comparing the Asymptotic Significance (p-value) to the predetermined level of significance ($alpha$), which is typically set at 0.05. This comparison determines whether we reject or fail to reject the null hypothesis.

In our example, the output shows an Asymp. Sig. value of 0.213. We compare this value to $alpha = 0.05$:

  1. If $p lt 0.05$, we reject the null hypothesis and conclude that there is a statistically significant difference in pain medians among the three drug groups.
  2. If $p ge 0.05$, we fail to reject the null hypothesis and conclude that there is no statistically significant evidence to suggest a difference in pain medians among the three drug groups.

Since $0.213$ is greater than $0.05$, we fail to reject the null hypothesis. The data does not provide sufficient statistical evidence to conclude that the three drugs have significantly different effects on reported knee pain after one month of treatment, based on the median pain scores.

If the result had been statistically significant ($p lt 0.05$), the next analytical step would be to perform post-hoc tests (such as Dunn’s test with a Bonferroni correction) to pinpoint exactly which pairs of drug groups differ significantly from each other. However, since our overall test was non-significant, further pairwise comparisons are not warranted.

Reporting the Kruskal-Wallis Test Findings

When documenting the results of the Kruskal-Wallis test in a formal research report or publication, it is essential to include the test statistic, the degrees of freedom, and the associated p-value. This transparency allows readers to fully understand the statistical basis of the conclusion. The reporting should also clearly state which hypothesis was tested and whether it was rejected or retained.

For the example scenario of drug efficacy, the statistical finding would be reported as follows: A Kruskal-Wallis H test was conducted to compare the distribution of knee pain scores across the three drug treatment groups (Drug 1, Drug 2, and Drug 3). The results indicated that there was no statistically significant difference in median pain scores among the three groups, $H(2) = 3.097$, $p = 0.213$.

This comprehensive approach ensures that the analysis is robust, particularly when dealing with non-normal data, and that the interpretation is directly linked to the calculated p-value and the underlying assumptions of the Kruskal-Wallis Test. Mastering this technique in SPSS is vital for researchers working across various disciplines where distribution assumptions are often violated.

Cite this article

Mohammed looti (2025). Learn How to Perform a Kruskal-Wallis Test in SPSS: A Step-by-Step Tutorial. PSYCHOLOGICAL STATISTICS. Retrieved from https://statistics.arabpsychology.com/perform-a-kruskal-wallis-test-in-spss/

Mohammed looti. "Learn How to Perform a Kruskal-Wallis Test in SPSS: A Step-by-Step Tutorial." PSYCHOLOGICAL STATISTICS, 8 Nov. 2025, https://statistics.arabpsychology.com/perform-a-kruskal-wallis-test-in-spss/.

Mohammed looti. "Learn How to Perform a Kruskal-Wallis Test in SPSS: A Step-by-Step Tutorial." PSYCHOLOGICAL STATISTICS, 2025. https://statistics.arabpsychology.com/perform-a-kruskal-wallis-test-in-spss/.

Mohammed looti (2025) 'Learn How to Perform a Kruskal-Wallis Test in SPSS: A Step-by-Step Tutorial', PSYCHOLOGICAL STATISTICS. Available at: https://statistics.arabpsychology.com/perform-a-kruskal-wallis-test-in-spss/.

[1] Mohammed looti, "Learn How to Perform a Kruskal-Wallis Test in SPSS: A Step-by-Step Tutorial," PSYCHOLOGICAL STATISTICS, vol. X, no. Y, ص Z-Z, November, 2025.

Mohammed looti. Learn How to Perform a Kruskal-Wallis Test in SPSS: A Step-by-Step Tutorial. PSYCHOLOGICAL STATISTICS. 2025;vol(issue):pages.

Download Post (.PDF)
Scroll to Top