'SMD for categorical variable using tbl_summary
The gtsummary::tbl_summary functionality is wonderful and I am looking for a way to add SMD for categorical variables. The tableone function provided smd for all types of covariates including character. I tried adding SMD to tbl_summary by add_stat with effsize::cohen.d or effsize::cohen.d. but both worked for numeric covariates and not for character. Any guidance is appreciated. Thanks
Solution 1:[1]
Use the add_difference() function with method "smd" to get the standardized mean differences. Review this page for a list of all available methods https://www.danieldsjoberg.com/gtsummary/reference/tests.html
library(gtsummary)
#> #Uighur
packageVersion("gtsummary")
#> [1] '1.5.2'
tbl <-
trial %>%
select(trt, age, response, grade) %>%
tbl_summary(by = trt, missing = "no") %>%
add_difference(everything() ~ "smd")
Created on 2022-03-03 by the reprex package (v2.0.1)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Daniel D. Sjoberg |
