Closed yuryzablotski closed 11 months ago
After the emmeans author wrote me the possibility to specify tau argument in emmeans, I figured out the solution
tbl_regression(qm10, add_pairwise_contrasts = T, emmeans_args = list(tau = .1))
He also said, that bei the next update of emmeans, the neccessaty to specify tau will be releaved.
sorry for circumstances! and thanks for your work! I am a bit fan and everyday user.
glad you found a resolution! happy programming!
Thanks Daniel,
one of the best gtsummary features for me is "add_pairwise_contrasts = T" via the integration with emmeans package, and amazingly it even by default uses the "weights = "prop". Special thanks for that! Hier is a code for non-0.5 quantile in a quantile regression which works perfectly:
library(ISLR) qm90 <- rq(wage ~ jobclass * health_ins, Wage, tau = 0.9)
emmeans(qm90, pairwise ~ jobclass|health_ins, type = "response", tau = 0.9)
emmip(qm90, jobclass ~ health_ins, tau = 0.9, CIs = T)
library(ISLR) qm90 <- rq(wage ~ jobclass + education + health_ins, Wage, tau = 0.9)
emmip(qm90, ~ education, tau = 0.9, CIs = T)+ theme_bw()
emmip(qm90, ~ education, tau = 0.9, CIs = T, weights = "prop")+ theme_bw()
emmeans(qm90, pairwise ~ education, weights = "prop")
tbl_regression( qm90, add_pairwise_contrasts = T, emmeans_args = list(tau = .9, weights = "prop"))
The "weights = "prop" is actually not necessary, which is cool!
Happy Christmal Holidays! Yury
Hi @yuryzablotski ! Thanks for the details! These calculations are expertly handled in the broom.helpers package. Can you copy the details in an issue on that repo? https://github.com/larmarange/broom.helpers
done!
Support for quantile regressions is only possible for tau = 0.5 (median regressio), however, the whole point of quantile regression is to be able to model quantiles:
works
d <- mtcars %>% mutate(cyl = factor(cyl)) m <- lm(mpg ~ cyl, d) library(gtsummary) tbl_regression(m, add_pairwise_contrasts = T)
works
library(quantreg) qm <- rq(mpg ~ cyl, d, tau = 0.5) tbl_regression(qm, add_pairwise_contrasts = T)
doesnt work
qm10 <- rq(mpg ~ cyl, d, tau = 0.1) tbl_regression(qm10, add_pairwise_contrasts = T)
by the way, emmeans with different quantiles work:
emmeans(qm10, pairwise ~ cyl, tau = 0.10, type = "response")
how can this be integrated into tbl_summary with add_pariwise_contrasts?
Thanks forword!