I am the author of the example you already mentioned in a comment. One of of the commentors already pointed out correctly where the .group
column came from. However, when pointing out the general difference between your code and the one in the example I find that
Data
1a. Your data has 1 observation per factor level (=Person).
1b. My data has multiple observations per factor level (=group).
Mean comparisons
2a. You used FSA::Dunntest
to fit a model and immediately compare means per factor level.
2b. I used lm()
to fid a model, then emmeans::emmeans()
to compare means per factor level.
Compact Letter Display
3a. You used rcompanion::cldList()
to get the letters.
3b. I used multcomp::cld()
to get the letters.
I think point 2 and 3 are totally fine - it's simply different functions leading to the same goal. I tried your approach on my data and it worked:
dunnTest_out <- FSA::dunnTest(weight ~ as.factor(group), method = "bh", data = PlantGrowth)
rcompanion::cldList(P.adj ~ Comparison, data = dunnTest_out$res, threshold = 0.05)
#> Group Letter MonoLetter
#> 1 ctrl ab ab
#> 2 trt1 a a
#> 3 trt2 b b
However, your data seems off to me. You shouldn't be able to compare "means" to each other and even perform tests (whose results can be displayed via the compact letter display) if your "means" are not actually means, but single values.
I simplified your example to one of the datasets:
dat_1.1.B <-
tibble::tribble(
~Person, ~Height, ~Weight,
"Luke", 177, 66,
"Alex", 169, 69,
"Haley", 145, 54
)
dunnTest_out <- FSA::dunnTest(Weight ~ as.factor(Person), method = "bh", data = dat_1.1.B)
dunnTest_out
#> Dunn (1964) Kruskal-Wallis multiple comparison
#> p-values adjusted with the Benjamini-Hochberg method.
#> Comparison Z P.unadj P.adj
#> 1 Alex - Haley 1.4142136 0.1572992 0.4718976
#> 2 Alex - Luke 0.7071068 0.4795001 0.4795001
#> 3 Haley - Luke -0.7071068 0.4795001 0.7192502
rcompanion::cldList(P.adj ~ Comparison, data = dunnTest_out$res, threshold = 0.05)
#> Error: No significant differences.
Note that it becomes really clear that something is not working correctly, when I change one of the Weight
values to a much larger number but the p-values do not change at all.
dat_1.1.B <-
tibble::tribble(
~Person, ~Height, ~Weight,
"Luke", 177, 66,
"Alex", 169, 100000069,
"Haley", 145, 54
)
dunnTest_out <- FSA::dunnTest(Weight ~ as.factor(Person), method = "bh", data = dat_1.1.B)
dunnTest_out
#> Dunn (1964) Kruskal-Wallis multiple comparison
#> p-values adjusted with the Benjamini-Hochberg method.
#> Comparison Z P.unadj P.adj
#> 1 Alex - Haley 1.4142136 0.1572992 0.4718976
#> 2 Alex - Luke 0.7071068 0.4795001 0.4795001
#> 3 Haley - Luke -0.7071068 0.4795001 0.7192502
rcompanion::cldList(P.adj ~ Comparison, data = dunnTest_out$res, threshold = 0.05)
#> Error: No significant differences.
So yeah, I think it's the data. Note that the error "No significant differences" is weird to me, too, because assuming the test was done correctly, no significant differences would simply mean that all values get the same letter.
tl;dr: The data is the problem. You cannot compare means via a test if your "means" are just single values per group. If you have the raw data that was used to get those single values per group, you should feed that into your model instead - as was done in my example and in the examples of ?FSA::Dunntest and ?rcompanion::cldList().