Difference between posthoc.kruskal.dunn.test and dunn.test

1.9k views Asked by At

I am currently searching a way to perform a dunn test in R. While doing that I came across multiple functions that have the Dunn test implemented.

library(dunn.test)
library(PMCMR)

dunn.test(x=mtcars[,"wt"], g= mtcars[,"cyl"])$P.adjusted

posthoc.kruskal.dunn.test(x=mtcars[,"wt"], g=mtcars[,"cyl"], p.adjust.method="bonferroni")

The results however are completely different. Does anyone have experience with the dunn.test package? I want to use the Dunns test as a posthoc test after the Kruskal Wallis test.

1

There are 1 answers

0
Axeman On

They use some different pre-sets. You can get identical results by applying a multiple testing correction and using alternative format p-values for the dunn.test:

dunn.test(x=mtcars[,"wt"], g= mtcars[,"cyl"], method = 'bonferroni', altp = TRUE)$P.adjusted
Kruskal-Wallis rank sum test

data: x and group
Kruskal-Wallis chi-squared = 22.8067, df = 2, p-value = 0


                           Comparison of x by group                            
                                 (Bonferroni)                                  
Col Mean-|
Row Mean |          4          6
---------+----------------------
       6 |  -1.836259
         |     0.1990
         |
       8 |  -4.755941  -2.221605
         |    0.0000*     0.0789

alpha = 0.05
Reject Ho if p <= alpha
posthoc.kruskal.dunn.test(x=mtcars[,"wt"], g=mtcars[,"cyl"], p.adjust.method="bonferroni")
Pairwise comparisons using Dunn's-test for multiple   
                         comparisons of independent samples 

data:  mtcars[, "wt"] and mtcars[, "cyl"] 

  4       6    
6 0.199   -    
8 5.9e-06 0.079

P value adjustment method: bonferroni