advanced analytics

Kruskal-Wallis Test for MS Excel
by Kilem L. Gwet. Ph.D.


Welcome to the website of the e-documents "The Kruskal-Wallis Test with Excel 2010 in 3 Simple Steps," and "The Kruskal-Wallis Test with Excel 2007 in 3 Simple Steps." The purpose of these documents is to show you a few simple steps for implementing the Kruskal-Wallis test using MS Excel (versions 2003, 2007, or 2010). The proposed solution is based on a user-friendly Excel Macro program called Kruskal-Wallis2007.xlsm (for Excel 2007 or earlier versions), or Kruskal-Wallis2010.xlsm (for Excel 2010). These macro programs require no installation at all and will do all the work for you. They come in the form of a stand-alone Excel workbook that you use to capture your input data and to perform the Kruskal-Wallis test. This is the simplest and most user-friendly method for conducting the Kruskal-Wallis test.

The free versions of these documents provide a detailed description of the Excel solutions for the Kruskal-Wallis test, and have the trial version of the Kruskal-Wallis Excel macro program attached to them. When you are statisfied with the solution (and you will surely be) then download the full version of the PDF document for only $9.95, with the full version of the Excel macro attached. Click here to see some screenshots.


Order Kruskal-Wallis with Excel 2010 for only $9.95 Order Kruskal-Wallis with Excel 2007 for only $9.95 Visit Advanced Analytics Press Online  

Kruskal-Wallis Test for Excel 2010 Kruskal-Wallis Test for Excel 2007

When you purchase one of these e- documents, you will get a complimentary copy of chapter 10 of my book entitled "The Practical Guide to Statistics: Basic Concepts, Methods, and Meaning. Applications with Excel, R, and OpenOffice Calc." Chapter 10 treats the ANOVA and related tests such as Kruskal-Wallis, Friedman, or ANOVA for dependent and independent samples.

What is the Kruskal-Wallist Test?

The single-factor ANOVA requires the law of probability underlying the data to be reasonably close to the Normal distribution, and the population variances to show some homogeneity. You may not feel comfortable with one or both of these assumptions. An alternative approach widely used by researchers is the Kruskal-Wallis test. It was suggested by Kruskal (1952) and, Kruskal and Wallis (1952), and requires the data to be ordinal. This test was designed primarily to compare population medians, and not population means. Should this
be a problem ? Not really. In fact, if the underlying populations are symmetric, population means and medians become identical. Otherwise, the median is what you should be interested in.

The Kruskal-Wallis test generalizes the Mann-Whitney test to 3 populations or more. Both tests are based on ranks instead of raw data, which makes them applicable to a variety of data types. In that sense, the Kruskal-Wallis test is another nonparametric test, which does not require the data to follow a particular law of probability. The downside being the loss of power due to the use of ranks in place of actual measurements.

The Kruskal-Wallis Test Statistic

Assuming that you want to compare k population means, the hypotheses would be formulated as follows:

kruskal-wallis hypotheses

Whether \mu_i represents the population mean or the population median is irrelevant when defining the Kruskal-Wallis test. You will not be estimating these parameters. Instead, you will merely be comparing them.

The Kruskal-Wallis test statistic will be denoted by H. It is calculated by first ranking all \n_textsc{t} observations (all samples combined) in ascending order from 1 to \n_textsc{t}. Let \ov{R}_{i\dot} be the average of the ranks associated with sample i, and \ov{R} the average of all ranks. The test staistic labeled as H is calculated as follows:

Kruskal-Wallis Test Statistic

where n_i is the number of observations in sample i. The law of probability associated with this test statistic is well approximated by the Chi-square distribution with k−1 degrees of freedom, when the null hypothesis is true. If the null hypothesis is true, then all population distributions would be the same. Any random sample taken from any population would yield approximately the same mean rank Ri·. This would lead to a small value for the H statistic, which by the way tells you how far you expect the mean rank from any given sample
to be away from the overall mean rank.

Let critical value for the kruskal-wallis test be the Kruskal-Wallis Percentile percentile of the chi-square distribution, where \alphais the significance level of the test. The decision rule for the Kruskal- Wallis test if formulated as follows:

kruskal-wallis decision rule

Validity Conditions

Several authors including Conover (1980, 1999), Daniel (1990), or Marascuilo and McSweeney (1977) mentioned a series of assumptions upon which they indicated the Kruskal-Wallis was based. These are:

  1. Each of the k samples is randomly selected from the population it represents. (A key aspect of this assumption is the need to avoid a large number of duplicates in the observations)
  2. The k samples under study are independent. (A key aspect of this assumption is to avoid using the Kruskal-Wallis test on repeated measurements taken on several occasions. Special repeated-measure procedures should be used (see Gwet (2011).)
  3. The analytic variable used for ranking is continuous. (This assumption is not critical to ensuring the validity of the Kruskal-Wallis test, and is often ignored by practitioners. The concern here is that if the null hypothesis of true, you want all k populations to be homogeneous, which may not quite be the case with discrete variables. If you are dealing with an unusual dataset, you may want to pay attention to this issue.)
  4. The probability distributions underlying the sample data are identical in their shape. (The purpose of this assumption is to ensure that a rejection of the null hypothesis can only be attributed to the difference in means.)
  5. Each independent sample has a size of 5 or more. (This ensures the validity of the chi-square approximation)

Download the e-book to learn more about the Kruskal-Wallis, and how ties for example are handled, and more ...

A portion of the output you will get after using one of the workbooks Kruskal-Wallis2007.xlsm or Kruskal-Wallis2010.xlsm
Excel output of the Kruskal-Wallis Test
A Look at the kruskal-wallis2010.xlsm and kruskal-wallis2007.xlsm workbooks before the program execution
Launching the kruskal-Wallis Excel Macro
A Look at the Input Dialog Form of the Kruskal-Wallis Excel Macro
Input Form of the Kruskal-Wallis Excel Macro
About the Author (Kilem L. Gwet, Ph.D) Contact Information
A statistical consultant, researcher and instructor. He has over 15 years of experience in various industries in the US and Canada. He possesses a doctorate degree in statistics from Carleton University - Canada -

Contact the author at,

  • info123@advancedanalyticsllc.com (Note: remove all numbers 123 from email address).
  • Advanced Analytics, LLC
    PO Box 2696
    Gaithersburg, MD 20886-2696