1

I'm using gtsummary package. I need to merge different univariate logistic regression and in order to have a good presentation, I want to hide the p_value and bold or put a star to the significant OR (p< 0.05).

Anyone can help me? Maybe it's easier to use another presentation type like kable, huxtable, I don't know?

Thank you for your help.

Have a nice day

Connell.O'Donnell
  • 3,603
  • 11
  • 27
  • 61

2 Answers2

1

There is a function called add_significance_stars() that hides the p-value and adds stars to the estimate indicating various levels of statistical significance. I've also added code to bold the estimate if significant with modify_table_styling().

library(gtsummary)
#> #BlackLivesMatter
packageVersion("gtsummary")
#> [1] '1.4.0'

tbl <-
  trial %>%
  select(death, age, grade) %>%
  tbl_uvregression(
    y = death, 
    method = glm,
    method.args = list(family = binomial),
    exponentiate = TRUE
  ) %>%
  # add significance stars to sig estimates
  add_significance_stars() %>%
  # additioanlly bolding significant estimates
  modify_table_styling(
    columns = estimate,
    rows = p.value < 0.05,
    text_format = "bold"
  )

enter image description here Created on 2021-04-14 by the reprex package (v2.0.0)

Daniel D. Sjoberg
  • 8,820
  • 2
  • 12
  • 28
0

Here's a quick huxtable version:

l1 <- glm(I(cyl==8) ~ gear, data = mtcars, family = binomial) 
l2 <- glm(I(cyl==8) ~ carb, data = mtcars, family = binomial) 

huxtable::huxreg(l1, l2, statistics = "nobs", bold_signif = 0.05)
                 ────────────────────────────────────────────────────
                                               (1)              (2)  
                                  ───────────────────────────────────
                   (Intercept)             5.999 *         -1.880 *  
                                          (2.465)          (0.902)   
                   gear                   -1.736 *                   
                                          (0.693)                    
                   carb                                     0.579 *  
                                                           (0.293)   
                                  ───────────────────────────────────
                   nobs                   32               32        
                 ────────────────────────────────────────────────────
                   *** p < 0.001; ** p < 0.01; * p < 0.05.           

Column names: names, model1, model2

It doesn't show it here, but the significant coefficients are bold on screen (and in any other kind of output).

dash2
  • 2,024
  • 6
  • 15