user20291515
user20291515

Reputation: 27

How do I add the effect size (partial eta squared) to a multipanel facet ggplot with p-values in R?

I have created a multipanel plot containing two groups by panels with the ggbarplot function. I followed a tutorial that instructed me how to display the p-values in the established star–bracket format by performing pairwise t-tests.

This is my code so far with some dummy data:

library(ggpubr)
library(rstatix)

df <- data.frame(id = rep(1:60, 3),
                 domain = c(rep("domain_1", 60),
                            rep("domain_2", 60),
                            rep("domain_3", 60)),
                 group = rep(c(rep("group_1", 20),
                               rep("group_2", 20),
                               rep("group_3", 20)), 3),
                 value = runif(n = 180, min = 1, max = 100))

# Facet by the domain variable and compare the levels of the group variable on the x-axis.
stat.test <- df %>%
  group_by(domain) %>%
  t_test(value ~ group) %>%
  #adjust_pvalue(method = "bonferroni") %>%
  add_significance()

# Auto-compute p-value label positions
stat.test <- stat.test %>% add_xy_position(x = "group", fun = "mean_se")

# Bar plot with p-values
ggbarplot(df, x = "group", y = "value", add = "mean_se", facet.by = "domain") +
  stat_pvalue_manual(stat.test, hide.ns = TRUE)

However, now I would also like to include the effect size of the performed inferential statistics. I am using the Partial Eta Squared measure. My impression is that I'll have to add something to the stat.test data frame, but I haven't succeeded so far. I also tried to add + stat_anova_test(effect.size = "pes") to the ggbarplot, but this didn't produce the correct results. A tough spot might be the fact that I used a t-test function and not an ANOVA. Any ideas?

Upvotes: 0

Views: 21

Answers (0)

Related Questions