# K independent samples

**When would I use this test?**

This is a test that can be used to analyse the variability of data, both within groups and between groups, when the samples are independent and are not normally distributed. This will show whether the variability between sample groups suggest they belong to likely the same population, or, if there are significant differences. In other words, this test can be used to test the null hypothesis that there is no difference in the distributions between the groups. The test can be done when there are multiple (k ≥ 2) different groups and is also called the Kruskal-Wallis test by ranks.

**How is the test done?**

The test is carried out using an extension of the Wilcoxon rank sum test.

**Benefits**

The test makes no assumptions about the distribution of data, and two or more groups (k ≥2) can be analysed.

**Disadvantages**

The test will not be able to tell you which specific groups are different from one another, just if at least two of the groups are different. A post hoc test such as Dunn’s test is needed to identify differences between specific groups/pairs.

**Worked Example**

Download below example excel file ‘Comparing k independent non parametric data’.

In the file there is a spreadsheet with two columns – Physical Activity Level and Weight (kg). The Physical activity level is split into four categories (Sedentary, Low, Medium and High).

- Click analyze ablove to open the Kruskal Wallis test function
- Browse your computer for ‘Comparing k independent non parametric data.xlsx’ (or the dataset you would like to analyse)
- Wait for it to upload
- If you have used a .csv file at this point you need to define your separator from the multiple options
- Select the variables you would like to analyse. For example ‘Physical Activity Level’ and ‘Weight (kg)’
- Define which is the continuous and which is the categorical variable (in this case Weight (kg) and Physical Activity Level respectively) from the drop down boxes
- If you select the ‘Kruskal Wallis’ tab you can now see the following:

[1] " x = Physical Activity Level AND y = Weight (kg)"

Kruskal-Wallis rank sum test

data: y by x

Kruskal-Wallis chi-squared = 5.6831, df = 3, p-value = 0.1281

As the P-value is greater than 0.05, we can conclude that there is insufficient evidence to reject the null hypothesis. This means that there is no statistically significant difference between the groups at the 5% level.

- If you would like to download your output, select the format and click download
- Congratulations you have run the Kruskal Wallis test function

Written By - Aneya Scott

**Resources: **Chapter 22, Medical Statistics at a Glance, Fourth Edition. Aviva Petrie and Caroline Sabin. © 2020 Aviva Petrie and Caroline Sabin. Published 2020 by John Wiley & Sons Ltd.