我有兴趣通过一个分层变量计算成对标准化平均差(SMD)。通常这是在两组之间计算,但我们可以在 3 组或更多组中进行此计算吗?
PS 我是 gtsummary 包的忠实粉丝,所以我尝试使用这个神奇包中的示例 2进行分析,如下所示:
library(tidyverse)
library(gtsummary)
#> #BlackLivesMatter
add_difference_ex2 <-
trial %>%
mutate(trt=ifelse(age<40,"Drug C", trt)) %>%
select(trt, age, marker, grade, stage) %>%
tbl_summary(
by = trt,
statistic = list(all_continuous() ~ "{mean} ({sd})"),
missing = "no",
include = c(age, marker, trt)
) %>%
add_n() %>%
add_difference(adj.vars = c(grade, stage))
#> 11 observations missing `trt` have been removed. To include these observations, use `forcats::fct_explicit_na()` on `trt` column before passing to `tbl_summary()`.
#> Error: 'tbl_summary'/'tbl_svysummary' object must have a `by=` value with exactly two levels
由reprex 包于 2021-10-27 创建(v2.0.1)