-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
Add an option contrast_adjust
to be passed to pairs()
when add_pairwise_contrasts = TRUE
#204
Comments
Did you try to use library(emmeans)
library(gtsummary)
m <- glm(am ~ cyl, mtcars %>% mutate(cyl = factor(cyl)), family = binomial)
emmeans(m, "cyl", type = "response") %>% pairs(reverse = T)
#> contrast odds.ratio SE df null z.ratio p.value
#> cyl6 / cyl4 0.2812 0.2870 Inf 1 -1.243 0.4279
#> cyl8 / cyl4 0.0625 0.0638 Inf 1 -2.717 0.0181
#> cyl8 / cyl6 0.2222 0.2400 Inf 1 -1.393 0.3448
#>
#> P value adjustment: tukey method for comparing a family of 3 estimates
#> Tests are performed on the log odds ratio scale
tbl_regression(m, add_pairwise_contrasts = TRUE) %>% as_kable()
emmeans(m, "cyl", type = "response") %>% pairs(reverse = T, adjust = "none")
#> contrast odds.ratio SE df null z.ratio p.value
#> cyl6 / cyl4 0.2812 0.2870 Inf 1 -1.243 0.2139
#> cyl8 / cyl4 0.0625 0.0638 Inf 1 -2.717 0.0066
#> cyl8 / cyl6 0.2222 0.2400 Inf 1 -1.393 0.1638
#>
#> Tests are performed on the log odds ratio scale
emm_options(contrast = list(adjust = "none"))
emmeans(m, "cyl", type = "response") %>% pairs(reverse = T)
#> contrast odds.ratio SE df null z.ratio p.value
#> cyl6 / cyl4 0.2812 0.2870 Inf 1 -1.243 0.2139
#> cyl8 / cyl4 0.0625 0.0638 Inf 1 -2.717 0.0066
#> cyl8 / cyl6 0.2222 0.2400 Inf 1 -1.393 0.1638
#>
#> Tests are performed on the log odds ratio scale
tbl_regression(m, add_pairwise_contrasts = TRUE) %>% as_kable()
Created on 2023-01-12 with reprex v2.0.2 |
contrast_adjust
to be passed to pairs()
when add_pairwise_contrasts = TRUE
yes, I tried to use it inside of both "tbl_regression()" and "tidy_add_pairwise_contrasts()", but could not manage to get method = "none" working. But now I tried this and it did work! (example below) Thanks! It is actually better when the default corrects for multiple comparisons, but, as you already changed the name of the issue, it would be nice, when the adjust = "none" would work directly inside of either tbl_regression() or add_pairwise_contrasts() or add_q(). Thanks again! make adjust = "none" the defaultemm_options(contrast = list(adjust = "none")) tbl_regression( return to "tukey" as a "termporary?" defaultemm_options(disable = TRUE) |
in `tidy_plus_plus()`, `tidy_add_pairwise_contrasts()` and `model_get_pairwise_contrasts()` allowing to change the adjustment method used to compute pairwise contrasts fix #204
Hi Joseph,
first, thanks a ton for {broom.helpers}! I am a big fan! Alone the "add_pairwise_contrasts" is incredibly useful!!! I started to use it on a daily basis and discovered a small inconsistency. Namely, adjust = "none", is not possible right now. And the add_pairwise_contrasts just uses Tukey (default from Emmeans) by default. Which is cool and fine, since we need to adjust for multiple testing, but if in the future you could implement "none" method of adjustment, that'll be cool. Below is the prove of this small issue. Kind regards! Yury
m <- glm(am ~ cyl, mtcars %>% mutate(cyl = factor(cyl)), family = binomial)
tbl_regression(
m,
exponentiate = T,
pvalue_fun = ~style_pvalue(.x, digits = 3),
add_pairwise_contrasts = T) %>%
add_n(location = "level") %>%
add_nevent(location = "level") %>%
add_significance_stars(hide_p = F, hide_se = T, hide_ci = F) %>%
add_q(method = "none")
emmeans(m, pairwise ~ cyl, type = "response")
emmeans(m, ~ cyl, type = "response") %>% pairs(reverse = T, adjust = "tukey")
emmeans(m, ~ cyl, type = "response") %>% pairs(reverse = T, adjust = "none")
The text was updated successfully, but these errors were encountered: