英文:
Using add_difference() function in gtsummary to present mean difference instead of standardized mean
问题
在使用add_difference函数创建表格时,如下面的示例所示,将呈现两个药物使用者之间的差异,以及95%的置信区间和p值。这个均值差异是标准化的,对于比例差异(例如二进制变量),实际差异与报告的差异略有不同。例如:两个药物使用者之间的实际肿瘤反应差异为-5%,但其报告的标准化差异为-4.2%。
trial %>%
select(-c("stage")) %>%
tbl_summary(by = trt,
statistic = list(
all_continuous() ~ "{mean} ({sd})",
all_categorical() ~ "{n} / {N} ({p}%)"
)) %>%
add_difference()
在这个示例中,是否有办法报告二进制变量的实际均值差异而不是标准化均值差异,并仍然获得均值的95%置信区间?(例如,肿瘤反应差异为-5%,而不是-4.2%或患者死亡差异为-6%,而不是-5.8%)
英文:
When creating a table with the add_difference function like the example below, the difference between the two drug users will be presented along with the 95% CI and a p-value. This mean difference is standardized, and for the difference between the proportions (e.g., binary variables) would be slightly different than the actual difference. Example: The actual Tumor response difference between the two drug users is -5%, but its reported standardized difference is -4.2%.
trial %>%
select(-c("stage")) %>%
tbl_summary(by = trt,
statistic = list(
all_continuous() ~ "{mean} ({sd})",
all_categorical() ~ "{n} / {N} ({p}%)"
)) %>%
add_difference()
Is there a way to report the actual mean difference instead of the standardized mean difference for the binary variables in this example and still get 95% CI for the mean? (e.g., Tumor-response difference -5% instead of -4.2% Or Patient-died difference to be -6% instead of -5.8%)
答案1
得分: 1
欢迎来到StackOverflow!
你在帖子中提到了二进制变量,所以我已经将表格子集化,只包括这些变量。
我认为你报告的问题只是舍入方式的差异。请参见下文。原始比率和比率差异的舍入都可以修改。
library(gtsummary)
packageVersion("gtsummary")
#> [1] '1.7.1'
trial %>%
select(trt, response, death) %>%
tbl_summary(
by = trt,
statistic = all_categorical() ~ "{p}%",
digits = all_categorical() ~ 2,
missing = "no"
) %>%
add_difference() %>%
as_kable()
特征 | 药物A,N = 98 | 药物B,N = 102 | 差异 | 95% CI | p-value |
---|---|---|---|---|---|
肿瘤反应 | 29.47% | 33.67% | -4.2% | -18%, 9.9% | 0.6 |
病人死亡 | 53.06% | 58.82% | -5.8% | -21%, 9.0% | 0.5 |
创建于2023年06月29日,使用reprex v2.0.2
英文:
Welcome to StackOverflow!
You mentioned the binary variables in your post, so I've subset the table to include those only.
I think the issue you're reporting is just a difference in rounding. See below. Rounding for both the raw rates and the rate difference can be modified.
library(gtsummary)
packageVersion("gtsummary")
#> [1] '1.7.1'
trial %>%
select(trt, response, death) %>%
tbl_summary(
by = trt,
statistic = all_categorical() ~ "{p}%",
digits = all_categorical() ~ 2,
missing = "no"
) %>%
add_difference() %>%
as_kable()
Characteristic | Drug A, N = 98 | Drug B, N = 102 | Difference | 95% CI | p-value |
---|---|---|---|---|---|
Tumor Response | 29.47% | 33.67% | -4.2% | -18%, 9.9% | 0.6 |
Patient Died | 53.06% | 58.82% | -5.8% | -21%, 9.0% | 0.5 |
<sup>Created on 2023-06-29 with reprex v2.0.2</sup>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论