Dunn's Test
Calculator
Learn More
Dunn's Test
Definition
Dunn's Test is a non-parametric post-hoc test used after a significant Kruskal-Wallis test to identify which specific groups differ from each other. It compares the difference in the sum of ranks between two groups with the expected average difference. This test is often used when the assumptions of ANOVA are violated, such as normality or homogeneity of variances.
Test Statistics
For comparing groups and :
Where:
- = mean ranks for groups and
- = sample sizes for groups and
- = total sample size
Key Features
Practical Example
Step 1: State the Data
Test scores for three different teaching methods:
Method A | Method B | Method C |
---|---|---|
23, 25, 21, 22, 20 | 18, 19, 17, 20, 21 | 15, 14, 16, 18, 19 |
Step 2: Rank All Data
Combined ranking of all values (lowest to highest):
Value | Rank | Group |
---|---|---|
14 | 1 | C |
15 | 2 | C |
16 | 3 | C |
17 | 4 | B |
18 | 5.5 | B,C |
19 | 7.5 | B,C |
20 | 9.5 | A,B |
21 | 11.5 | A,B |
22 | 13 | A |
23 | 14 | A |
25 | 15 | A |
Step 3: Calculate Mean Ranks
- Method A:
- Method B:
- Method C:
Step 4: Calculate Test Statistics
For each pair (using the formula):
- A vs B:
- A vs C:
- B vs C:
Step 5: Apply Bonferroni Correction
For 3 groups, we have 3 comparisons:
- Adjusted
- Critical value
Step 6: Draw Conclusions
- A vs B: Significant ()
- A vs C: Significant ()
- B vs C: Not significant ()
Method A scores significantly differ from C. However, there is no evidence to suggest a significant difference between the scores of Method A and Method B or Method B and Method C.
Code Examples
1library(tidyverse)
2library(FSA)
3
4# Data preparation
5data_long <- tibble(
6 Method = rep(c("Method A", "Method B", "Method C"), each = 5),
7 Value = c(23, 25, 21, 22, 20, 18, 19, 17, 20, 21, 15, 14, 16, 18, 19)
8)
9
10# Perform Kruskal-Wallis test
11kruskal_test <- kruskal.test(Value ~ Method, data = data_long)
12print(kruskal_test)
13
14# Perform Dunn's test with Bonferroni correction
15dunn_test <- dunnTest(Value ~ Method, data = data_long, method = "bonferroni")
16print(dunn_test)
1import scikit_posthocs as sp
2import pandas as pd
3import numpy as np
4
5# Example data
6group1 = [23, 25, 21, 22, 20]
7group2 = [18, 19, 17, 20, 21]
8group3 = [15, 14, 16, 18, 19]
9
10# Create a DataFrame
11data = pd.DataFrame({
12 'values': group1 + group2 + group3,
13 'groups': ['A']*5 + ['B']*5 + ['C']*5
14})
15
16# Perform Dunn's test
17dunn = sp.posthoc_dunn(data, val_col='values', group_col='groups', p_adjust='bonferroni')
18print(dunn)
Alternative Tests
Consider these alternatives:
- Tukey's HSD: When data is normally distributed
- Games-Howell: When variances are unequal
- Nemenyi Test: Another non-parametric alternative
Related Calculators
Kruskal-Wallis Test Calculator
Mann-Whitney U Test Calculator
Friedman Test Calculator
One-Way ANOVA Calculator
Help us improve
Found an error or have a suggestion? Let us know!