You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
I am using stat_compare_means() to carry out an anova. I need to also carry out the post-hoc Tukey test and would like to add p value comparisons to the figure, as is possible with the Kruskal-Wallis test.
So currently Kruskal-Wallis, followed by the post-hoc Dunn test can be implemented as:
my_comparisons <- list( c("0.5","1"),c("1","2"),c("0.5","2"))
df <- ToothGrowth
ggbarplot(data=df,"dose","len", add = c("mean_se")) +
stat_compare_means(comparisons = my_comparisons)
I am picturing the code for anova followed by Tukey test looking something like this:
my_comparisons <- list( c("0.5","1"),c("1","2"),c("0.5","2"))
df <- ToothGrowth
ggbarplot(data=df,"dose","len", add = c("mean_se")) +
stat_compare_means(method="anova", comparisons = my_comparisons)
Best wishes
for pairwise-comparison between groups, you need to specify method = "t.test" (Instead of anova) or method = "wilcox.test"
my_comparisons <- list( c("0.5","1"),c("1","2"),c("0.5","2"))
df <- ToothGrowth
ggbarplot(data=df,"dose","len", add = c("mean_se")) +
stat_compare_means(method="t.test", comparisons = my_comparisons)
#
Tukey HSD
library(
rstatix
)
#
https://github.com/kassambara/rstatix
stat.test
<-
aov(
len
~
dose
,
data
=
df
) %
>
%
tukey_hsd()
# A tibble: 3 x 8
term group1 group2 comparison estimate conf.low conf.high p.adj
1 dose 0.5 1 1-0.5 9.130 5.901805 12.358195 2.0e-08
2 dose 0.5 2 2-0.5 15.495 12.266805 18.723195 1.1e-11
3 dose 1 2 2-1 6.365 3.136805 9.593195 4.2e-05
# Visualize
library(ggpubr)
ggboxplot(df, x = "dose", y = "len") +
stat_pvalue_manual(
stat.test, label = "p.adj",
y.position = c(29, 35, 39)
ropolomx, EmilioEm, RosarioIacono, Ryxicon, guatavita, millerh1, MichaelPeibo, leowill01, biobibibi, angelolimeta, and 4 more reacted with thumbs up emoji
bernardojoconnor and Minh-AnhHuynh reacted with hooray emoji
All reactions
I found a way around it but this is a simpler way to it. Thank you!
On Fri, Aug 10, 2018 at 6:41 PM Alboukadel KASSAMBARA < ***@***.***> wrote:
Closed
#102 <
#102>.
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<
#102 (comment)>, or mute
the thread
<
https://github.com/notifications/unsubscribe-auth/AoMCywGkn8KekASsXTSY_knjx8XSlxUBks5uPcXkgaJpZM4VgUnA>
Thank you kassambara for a nice explanation. I have a similar problem, but with stat_compare_means. How could I include a Tukey test in this function, instead of a t.test, wilcox, kruskal anova?
I tried your code with stat.test. However, I get the following error:
Warning messages:
1: Computation failed in stat_compare_means()
:
Non-supported method specified. Allowed methods are one of: t.test, t.test, t.test, wilcox.test, wilcox.test, wilcox.test, anova, anova, kruskal.test, kruskal.test
Is there a way to do the same thing with the outputs of glht like so:
stat.test <- aov(len ~ dose, data = df) %>%
summary(glht(., linfct=mcp(dose="Dunnett")))
Hi guys,
Just a silly question, was Dunn's test finally implemented? @BlueCeramicRipples structured an answer, but I guess this way applied only ANOVA.
Any suggestions in this regard?
Best wished and be safe!
As a follow up on the question from @Rhodnius : Which test is performed when doing pairwise comparisons + global p value as stated in your docs?
"p + stat_compare_means(comparisons = my_comparisons)+ # Add pairwise comparisons p-value
stat_compare_means(label.y = 50) # Add global p-value"
My plan is to implement Kruskal-Wallis + Dunn's for a faceted plot, each facet containing 3 groups. Is it automatically the case that Dunn's is used for the pairwise comparisons if you chose Kruskal?
tukey_hsd()
@kassambara Could you please tell me how we could use ANOVA-Post Hoc Test for grouped data?
I want to get something similar to this picture but people always just show t.test.
Thank you very much!