如何使用生存分析计算药物保留率的置信区间

How to calculate confidence intervals for drug retention rates using survival analysis

我是 R 中生存分析的新手。我看到我的同事设法找到特定时间间隔(6 个月、12 个月、24 个月)的药物保留率为 95% CI。我该怎么做?

这是一个可重现的例子:

library(survival) 
library(survminer)
gender <- as.factor(c("Female", "Male", "Female", "Male", "Male", "Male", "Female", "Female", "Female", "Male"))
country <- as.factor(c("US", "US", "GB", "GB", "GB", "US", "GB", "US", "GB", "US"))
time <- c(5, 10, 12, 15, 20, 9, 14, 18, 24, 20)
event <- c(1, 1, 1, 1, 1, 0, 0, 1, 0, 1)
df <- data.frame(gender, country, time, event)
km.model <- survfit(Surv(time = df$time, event = df$event) ~ gender, data = df)
km.model
ggsurvplot (km.model, data = df, conf.int = TRUE, risk.table = "abs_pct", xlab = "Time in months")

提前致谢!

您可以在需要的时间间隔内使用 summary: 这将提供所需的 CI。

summary(km.model, times = seq(0, 24, 6))

输出:

  gender=Female 
 time n.risk n.event survival std.err lower 95% CI upper 95% CI
    0      5       0      1.0   0.000       1.0000            1
    6      4       1      0.8   0.179       0.5161            1
   12      4       1      0.6   0.219       0.2933            1
   18      2       1      0.3   0.239       0.0631            1
   24      1       0      0.3   0.239       0.0631            1

                gender=Male 
 time n.risk n.event survival std.err lower 95% CI upper 95% CI
    0      5       0     1.00   0.000        1.000            1
    6      5       0     1.00   0.000        1.000            1
   12      3       1     0.75   0.217        0.426            1
   18      2       1     0.50   0.250        0.188            1