Closed IndrajeetPatil closed 5 years ago
@ibecav Can you please have a look at this issue and see if you can figure out what's going on?
Yes. The good news is your code is correct and this is actually the "right" answer. Or perhaps more clearly this is the expected result. Remember these are family wide comparisons and therefore you shouldn't expect the same answer when you change the "size" of the vore "family" between 2 factor levels and 4 factor levels.
Tukey HSD tests differences between each mean as compared to the critical value that is set for the test of the means that are furthest apart which changes a lot when you add in the factors for herbi and insecti
There's something more troubling here though that I'll comment on in a minute but this issue is a non issue.
Okay, I finally sorted my way through what was troubling me. First I hadn't realized you were using Games-Howell exclusively when var.equal = FALSE
that's fine but probably should get mentioned in the doco.
As the reprex shows below you're currently adjusting p values but not confidence intervals when var.equal = TRUE
don't know whether it's worth it to add another package to adjust them...
# reprex
set.seed(123)
library(tidyverse, warn.conflicts = FALSE)
library(ggstatsplot)
# If the user selects var.equal false they always get Games Howell
# for var.equal = TRUE
# Currently the p values are adjusted but the CI's aren't they're all default Tukey
# HSD
# default holm
pairwise_p(data = msleep,
x = vore,
y = brainwt,
var.equal = TRUE,
messages = FALSE) %>%
filter(group1 == "omni", group2 == "carni")
#> group1 group2 mean.difference conf.low conf.high p.value significance
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 omni carni 0.0665 -1.05 1.18 1 ns
# switch to Bonferroni
pairwise_p(data = msleep,
x = vore,
y = brainwt,
p.adjust.method = "bonferroni",
var.equal = TRUE,
messages = FALSE) %>%
filter(group1 == "omni", group2 == "carni")
#> group1 group2 mean.difference conf.low conf.high p.value significance
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 omni carni 0.0665 -1.05 1.18 1 ns
# Try none
pairwise_p(data = msleep,
x = vore,
y = brainwt,
p.adjust.method = "none",
var.equal = TRUE,
messages = FALSE) %>%
filter(group1 == "omni", group2 == "carni")
#> group1 group2 mean.difference conf.low conf.high p.value significance
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 omni carni 0.0665 -1.05 1.18 0.875 ns
# as opposed to adjusting both
library(DescTools)
# build the aov model
a2 <- aov(brainwt ~ vore, msleep)
# feed it to DescTools::PostHocTest
# DescTools::PostHocTest(a2, method = "hsd")
# Tukey
as_tibble(DescTools::PostHocTest(a2, method = "hsd")$vore, rownames = "group1-group2") %>%
filter(`group1-group2` == "omni-carni")
#> # A tibble: 1 x 5
#> `group1-group2` diff lwr.ci upr.ci pval
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 omni-carni 0.0665 -1.05 1.18 0.999
# Bonferroni
as_tibble(DescTools::PostHocTest(a2, method = "bonferroni")$vore, rownames = "group1-group2") %>%
filter(`group1-group2` == "omni-carni")
#> # A tibble: 1 x 5
#> `group1-group2` diff lwr.ci upr.ci pval
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 omni-carni 0.0665 -1.09 1.22 1
# Scheffe
as_tibble(DescTools::PostHocTest(a2, method = "scheffe")$vore, rownames = "group1-group2") %>%
filter(`group1-group2` == "omni-carni")
#> # A tibble: 1 x 5
#> `group1-group2` diff lwr.ci upr.ci pval
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 omni-carni 0.0665 -1.15 1.28 0.999
Created on 2019-03-11 by the reprex package (v0.2.1)
The exact test used for pairwise multiple comparisons is displayed in the caption itself and the caption adjusts itself based on the var.equal
and p.adjust.method
arguments. But you think we should also include these details in the roxygen
documentation?
For the issue of adjusting CIs for multiple comparisons in output from pairwise_p
, I'd much prefer to just drop the columns containing confidence intervals. The sole function of pairwise_p()
is to generate p-values that can be used to create appropriate comparison geoms in ggbetweenstats
and ggwithinstats
. All the additional details it provides are incidental (and not consistent across tyoes of tests). I don't think it's worth it to gain an additional dependency just to provide these details. If adjusted CIs for post-hoc comparisons is what people want, there are multiple other R packages that the users can rely on.
I agree on not needing to add more I'd just mention in one sentence that if var.equal = FALSE
you're always going to use G-H
Why are the confidence intervals and p-values different here when everything else (t, df, etc.) remains the same?!
Created on 2019-02-22 by the reprex package (v0.2.1.9000)