4 C
London
Friday, December 20, 2024
HomeRANOVA in RHow to Perform Dunn’s Test in R

How to Perform Dunn’s Test in R

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

A Kruskal-Wallis test is used to determine whether or not there is a statistically significant difference between the medians of three or more independent groups. It is considered to be the non-parametric equivalent of the One-Way ANOVA.

If the results of a Kruskal-Wallis test are statistically significant, then it’s appropriate to conduct Dunn’s Test to determine exactly which groups are different.

This tutorial explains how to perform Dunn’s Test in R.

Example: Dunn’s Test in R

A researcher wants to know whether or not three drugs have different effects on back pain, so he recruits 30 individuals who all experience similar back pain and randomly splits them up into three groups to receive either Drug A, Drug B, or Drug C. After one month of taking the drug, the researcher asks each individual to rate their back pain on a scale of 1 to 100, with 100 indicating the most severe pain.

The researcher conducts a Kruskal-Wallis test using a .05 significance level to determine if there is a statistically significant difference between the median back pain ratings across these three groups.

The following code shows how to create the data frame in R and perform a Kruskal-Wallis test:

#make this example reproducible
set.seed(0)

#create data frame
data 

#view first six rows of data frame
head(data)

#  drug     pain
#1    A 57.93394
#2    A 45.31017
#3    A 47.44248
#4    A 51.45707
#5    A 58.16416
#6    A 44.03364

#perform Kruskal-Wallis Test
kruskal.test(pain ~ drug, data = data)

	Kruskal-Wallis rank sum test

data:  pain by drug
Kruskal-Wallis chi-squared = 11.105, df = 2, p-value = 0.003879

Since the overall p-value (0.003879) is less than .05, this means there is a statistically significant difference between the reported pain levels among the three drugs. Thus, we can perform Dunn’s test to determine exactly which drugs are different.

The following code shows how to perform Dunn’s Test in R by using the dunnTest() function from the FSA() library:

#load library
library(FSA)

#perform Dunn's Test with Bonferroni correction for p-values
dunnTest(pain ~ drug,
         data=data,
         method="bonferroni")

Dunn (1964) Kruskal-Wallis multiple comparison
  p-values adjusted with the Bonferroni method.

  Comparison          Z     P.unadj       P.adj
1      A - B -0.8890009 0.374002602 1.000000000
2      A - C -3.2258032 0.001256197 0.003768591
3      B - C -2.3368023 0.019449464 0.058348393

Note that we chose to use a Bonferroni correction for the p-values of the multiple comparisons, but other possible options include:

  • “sidak” (Sidak adjustment)
  • “holm” (Holm Adjustment)
  • “hs’ (Holm-Sidak Adjustment)
  • “bs” (Bonferroni-Sidak Adjustment)
  • “by” (Benjamini-Yekuteili Adjustment)
  • “bh” (Benjamini-Hochberg procedure)

At α = .05, drugs A and C are the only two drugs that are statistically significantly different from each other (adjusted p-value = .003768).

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories