Home > Net >  Increasing the number of digits in dunn.test p-values
Increasing the number of digits in dunn.test p-values

Time:12-30

I am using the dunn.test() function from the package to do a pairwise comparison of groups after a Kruskal-Wallis that showed significant differences in means.

The dunn.test() function only reports to the 4th decimal place, though. One of the comparisons is reported as 0.0000. I have attempted to increase the number of digits that it reports using options(digits = 10), but this does not increase the number of decimal places.

This there any way to increase the number of digits this function reports?

Here is an example:

my_data <- structure(list(species = 
        c("ABIBAL", "ABIBAL", "ABIBAL", "ACEPEN", "ACEPEN", "ACEPEN", "ACERUB", "ACERUB", "ACERUB", "ACESAC", "ACESAC", 
        "ACESAC", "ACESPI", "ACESPI", "ACESPI", "ARANUD", "ARANUD", "ARANUD", 
        "ARITRI", "ARITRI", "ARITRI", "ATHANG", "ATHANG", "ATHANG", "BETALL", 
        "BETALL", "BETALL", "CARARC", "CARARC", "CARARC", "CARINT", "CARINT", 
        "CARINT", "CINLAT", "CINLAT", "CINLAT", "CLIBOR", "CLIBOR", "CLIBOR", 
        "DENPUN", "DENPUN", "DENPUN", "DRYCAM", "DRYCAM", "DRYCAM", "DRYINT", 
        "DRYINT", "DRYINT", "FAGGRA", "FAGGRA", "FAGGRA", "FRAAME", "FRAAME", 
        "FRAAME", "HUPLUC", "HUPLUC", "HUPLUC", "LONCAN", "LONCAN", "LONCAN", 
        "MAICAN", "MAICAN", "MAICAN", "MAIRAC", "MAIRAC", "MAIRAC", "MEDVIR", 
        "MEDVIR", "MEDVIR", "NABSPP", "NABSPP", "NABSPP", "OCLACU", "OCLACU", 
        "OCLACU", "OXAMON", "OXAMON", "OXAMON", "PARNOV", "PARNOV", "PARNOV", 
        "PHECON", "PHECON", "PHECON", "PICRUB", "PICRUB", "PICRUB", "RUBIDA", 
        "RUBIDA", "RUBIDA", "SAMRAC", "SAMRAC", "SAMRAC", "STRAMP", "STRAMP", 
        "STRAMP", "TIACOR", "TIACOR", "TIACOR", "TRIBOR", "TRIBOR", "TRIBOR", 
        "TRIERE", "TRIERE", "TRIERE", "TRIUND", "TRIUND", "TRIUND", "TSUCAN", 
        "TSUCAN", "TSUCAN", "UVUSES", "UVUSES", "UVUSES", "VIBLAN", "VIBLAN", 
        "VIBLAN", "VIOBLA", "VIOBLA", "VIOBLA", "VIOROT", "VIOROT", "VIOROT"), 
        name = c("all_3", "topo_spectral_3", "universal", "all_3", 
        "topo_spectral_3", "universal", "all_3", "topo_spectral_3", "universal", 
        "all_3", "topo_spectral_3", "universal", "all_3", "topo_spectral_3", 
        "universal", "all_3", "topo_spectral_3", "universal", "all_3", 
        "topo_spectral_3", "universal", "all_3", "topo_spectral_3", "universal", 
        "all_3", "topo_spectral_3", "universal", "all_3", "topo_spectral_3", 
        "universal", "all_3", "topo_spectral_3", "universal", "all_3", 
        "topo_spectral_3", "universal", "all_3", "topo_spectral_3", "universal", 
        "all_3", "topo_spectral_3", "universal", "all_3", "topo_spectral_3", 
        "universal", "all_3", "topo_spectral_3", "universal", "all_3", 
        "topo_spectral_3", "universal", "all_3", "topo_spectral_3", "universal", 
        "all_3", "topo_spectral_3", "universal", "all_3", "topo_spectral_3", 
        "universal", "all_3", "topo_spectral_3", "universal", "all_3", 
        "topo_spectral_3", "universal", "all_3", "topo_spectral_3", "universal", 
        "all_3", "topo_spectral_3", "universal", "all_3", "topo_spectral_3", 
        "universal", "all_3", "topo_spectral_3", "universal", "all_3", 
        "topo_spectral_3", "universal", "all_3", "topo_spectral_3", "universal", 
        "all_3", "topo_spectral_3", "universal", "all_3", "topo_spectral_3", 
        "universal", "all_3", "topo_spectral_3", "universal", "all_3", 
        "topo_spectral_3", "universal", "all_3", "topo_spectral_3", "universal", 
        "all_3", "topo_spectral_3", "universal", "all_3", "topo_spectral_3", 
        "universal", "all_3", "topo_spectral_3", "universal", "all_3", 
        "topo_spectral_3", "universal", "all_3", "topo_spectral_3", "universal", 
        "all_3", "topo_spectral_3", "universal", "all_3", "topo_spectral_3", 
        "universal", "all_3", "topo_spectral_3", "universal"), 
        value = c(0.805, 0.729, 0.611, 0.84, 0.729, 0.636, 0.682, 0.592, 0.497, 0.764, 
        0.762, 0.666, 0.783, 0.668, 0.596, 0.828, 0.735, 0.684, NA, 0.736, 
        0.715, 0.765, 0.758, 0.636, 0.704, 0.626, NA, NA, NA, NA, 0.771, 
        0.589, NA, 0.799, 0.649, 0.583, 0.733, 0.753, NA, 0.694, 0.647, 
        NA, NA, NA, NA, 0.82, 0.833, 0.717, 0.821, 0.821, 0.747, 0.766, 
        0.717, 0.675, 0.742, 0.667, 0.704, NA, 0.591, NA, 0.793, 0.76, 
        0.74, 0.782, 0.747, 0.599, 0.755, 0.699, 0.586, 0.738, 0.652, 
        0.572, 0.62, 0.522, NA, 0.753, 0.531, 0.546, NA, NA, 0.51, 0.736, 
        0.708, 0.572, 0.657, 0.704, 0.638, 0.694, 0.675, NA, 0.769, 0.739, 
        0.717, NA, NA, 0.6, 0.77, 0.678, 0.732, 0.735, 0.697, NA, 0.83, 
        0.705, 0.585, 0.709, 0.683, 0.633, NA, NA, NA, 0.749, 0.748, 
        0.595, 0.827, 0.725, 0.722, 0.744, 0.676, 0.634, 0.799, 0.793, 
        0.68)), row.names = c(NA, -123L), class = c("tbl_df", "tbl", "data.frame"))


dunn.test::dunn.test(my_data$value,
                     my_data$name, 
                     method = "bonferroni")

Thanks!

CodePudding user response:

If you assign the output of that function call to an object name, say res then you can see that the p-values are present:

str(res)
List of 5
 $ chi2       : num 39
 $ Z          : num [1:3] 3.61 6.21 2.8
 $ P          : num [1:3] 1.54e-04 2.68e-10 2.55e-03
 $ P.adjusted : num [1:3] 4.63e-04 8.05e-10 7.66e-03
 $ comparisons: chr [1:3] "all_3 - topo_spectral_3" "all_3 - universal" "topo_spectral_3 - universal"

If you want then printed with the default number of significant figures you can just use the default print operation implied by the REPL behavior of the R console:

res$P.adjusted
[1] 4.629094e-04 8.053304e-10 7.663309e-03

CodePudding user response:

If, like in IRTFM's answer, you assign the test return value to a variable res, you will be able to see the value corresponding to the printed (in fact with cat) 0.0000* coming from group comparison "all_3 - universal".

The value printed is the P.adjusted list member.

res <- dunn.test::dunn.test(my_data$value,
                            my_data$name, 
                            method = "bonferroni")

i <- which(res$comparisons == "all_3 - universal")
res$P[i]
#[1] 2.684435e-10
res$P.adjusted[i]
#[1] 8.053304e-10
  • Related