# Comparison between groups

I have to compare three groups. Three measurements using 3 different methods on the same subjects. The variables are not normal, and the measures concern the same people, so dependent samples. I can use Kruskal-Wallis? I can use Wilcoxon post analysis with Bonferroni correction? How can I use the Bonferroni correction in R? Can I have examples?

• I would advise usage of a specific post-hoc test such as Dunn's or Nemenyi test which can be found in PMCMR package. – Andrey Kolyadin Feb 17 '17 at 12:28
• Thank you, but for the comparison of the three groups? – ANDREA NIGRI Feb 17 '17 at 13:49
• There are no reasons to use post-hoc test for less than 3 groups. Both Dunn's test and Nemenyi test are working perfectly fine with 3 and more groups. – Andrey Kolyadin Feb 17 '17 at 13:54
• thank you but my group are 3 – ANDREA NIGRI Feb 17 '17 at 14:01

It seems some misunderstanding have arose in comments, so here is an answer.

Why we shouldn't use Wilcoxon test as post-hoc?

Pairwise Wilcox-Mann-whitney test doesn't take into account ranks from Kruskal-Wallis test, it creates it's own. On the other side Dunn's test use group ranking from KW test.

Example with R:

set.seed(pi)
df <- data.frame(val = c(runif(15,  0, 15),
runif(15,  0, 15),
runif(15, 10, 20)),
grp = rep(c('A', 'B', 'C'), each = 15))

kruskal.test(val ~ grp, df)

Kruskal-Wallis rank sum test

data:  val by grp
Kruskal-Wallis chi-squared = 22.045, df = 2, p-value = 1.633e-05


So Kruskal-Wallis test tells us that there is statistically significant differences between groups. But we need to run Dunn's test to know between which pairs of group we have difference .

require(PMCMR)
posthoc.kruskal.dunn.test(val ~ grp, df)

Pairwise comparisons using Dunn's-test for multiple
comparisons of independent samples

data:  val by grp

A       B
B 0.96674 -
C 0.00013 0.00013


In case of dependent samples Friedman test with appropriate post-hoc (Conover test in PMCMR for example) should be used. But general approach (just with correct tests) I showed above is still applicable.