0

I have the following dataset

df1 <- data.frame(
  ANT = rep(c("flat", "curved"), c(67L, 48L)),
  BUT = rep(rep(c("LOW", "HIGH", "MEDIUM"), 2), c(25L, 22L, 20L, 17L, 17L, 14L)),
  var = c(
    14.0893991925757, 34.5484885681107, 20.7174240548614, 25.4998196190733,
    31.4186155350739, 23.9418025873478, 29.2952697205706, 31.0074678953528,
    29.9488827390121, 18.6431675883043, 26.2561373793794, 28.0340456886336,
    21.3315213355736, 25.3895679668835, 21.1835920085372, 22.0677507628379,
    20.1366209392779, 25.6779779639275, 18.5595294368952, 24.3482565168431,
    21.4886619372012, 18.2566017946862, 21.7690284772916, 19.473773134573,
    19.8761647389968, 22.847746252395, 29.8983780052465, 21.2638059591326,
    21.4989273413039, 23.8097080965946, 23.9277561144883, 27.5962255868355,
    23.4600141179236, 26.7134452330659, 19.9017649500486, 24.7220153820575,
    22.8426620960118, 24.3827214266648, 24.5370516165671, 18.8226726423951,
    20.4818642523004, 23.4007024865177, 24.4261112825149, 22.7252596157298,
    24.8050004701495, 17.1391568096686, 15.8109102498205, 18.1241654660625,
    21.4823271079496, 21.1400794352986, 27.3534014635139, 20.2000403766816,
    21.8824213710077, 26.0958004452957, 25.6236659003885, 23.6333743675666,
    26.0654323617309, 23.2238669517486, 22.1475210827, 20.6385543814378,
    22.2741071397729, 22.0322908777281, 22.3013435962846, 23.3855560627095,
    14.777645399919, 22.8718755830401, 20.1109090151846, 30.5945414441111,
    25.5246847421648, 24.5963562212877, 21.0462714186863, 24.2620804213428,
    31.2174463426269, 25.9255483794558, 23.8015456288551, 28.0678758121308,
    29.1334565132879, 26.5456192083438, 25.8166079071426, 28.5893484517149,
    22.9149648377856, 21.3707158335156, 25.6345655011601, 27.2245037265109,
    34.3865189209535, 23.6522777623383, 28.0153190912664, 31.0000579224744,
    24.2508784612085, 32.5540674480317, 22.3182172886118, 27.7700467757006,
    29.3100094241364, 30.9548789492215, 23.1372007918014, 27.2781982742886,
    24.5118551940972, 21.0561505635071, 19.4749294149819, 20.7808819790676,
    26.8835213854079, 32.8620732685946, 25.2672058281747, 19.7246120101459,
    21.8437412033618, 25.5544947006571, 24.1231862605842, 27.6489683449072,
    28.1944505360829, 30.899675939765, 24.6982404630626, 27.6476409055514,
    23.9858852018033, 24.8350189243816, 21.2453610459381
  )

where I got some statistics:

df <- tibble::tibble(
  ANT = rep(c("curved", "flat"), each = 3L),
  BUT = rep(c("HIGH", "LOW", "MEDIUM"), 2),
  mean = c(
    26.3138240968879, 26.0156548464778, 25.6093253309293, 22.955177272156,
    23.7183827032728, 22.268218919301
  ),
  low = c(
    25.2487948926047, 25.3069032211294, 24.6433224275379, 22.2624629363964,
    22.728343059147, 21.624306894361
  ),
  up = c(
    27.3788533011711, 26.7244064718262, 26.5753282343208, 23.6478916079156,
    24.7084223473986, 22.9121309442411
  ),
)

and here are stored the label to add to the graph about multi pairwise comparison

val = df1 %>% dplyr::group_by(ANT) %>% pairwise_t_test(var ~ BUT) %>%
  add_xy_position(x = "BUT") %>%  mutate(lab = paste(p," - ", p.adj.signif), 
                                         lb = paste0(group1, " vs ", group2, ": p=", lab)) 

I cannot understand why while the plot seems to be a statistical difference (because error bars do not overlap), I cannot in the statistics I have in the val dataset. Am I doing something wrong with the pairwise_t_test function? Is an alternative way to check and get the label for pairwise comparison for a model I am trying to plot (var ~ ANT*BUT) that probably I cannot achieve with this function?

ggplot(df, 
           aes(x= BUT, y= mean, 
               colour= ANT, group = ANT)) +
    
    geom_errorbar(aes(ymin= low, 
                      ymax= up), 
                  colour="black", width=.10) +
    geom_line() + 
    geom_point(size= 3, shape= 21, fill="white") + 
    stat_pvalue_manual(
      val, 
      step.increase=0.05,label = "lab", y.position = 28)

Here are the plot and statistics that I got.

moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
12666727b9
  • 1,133
  • 1
  • 8
  • 22
  • For me, not reliable at all ... besides `dplyr`, what other non-base packages are you using? `pairwise_t_test` is not commonly discussed as far as I see, and it has similarly-named functions in a number of packages, each of which (I'm sure) have nuances or differences between them. – r2evans Apr 28 '23 at 19:18
  • Could you please suggest a small response? Actually I am just looking for a reliable that shows interaction for BUT*ANT – 12666727b9 Apr 29 '23 at 05:32

0 Answers0