提取 Kaplan-Meier 阶跃函数
Extracting Kaplan-Meier step function
我想做的是在来自 MICE 的 5 个估算数据集上拟合 5 条 Kaplan Meier 曲线。我的目标是在每个时间点取 5 个生存概率的平均值。如果我有构成每条 KM 曲线的阶跃函数的确切形式,我认为这会很容易,但我不知道如何提取它。
这是我要 运行
的代码示例
#make up data
survival_time=rexp(10,3)
dead=sample(c(0,1),10,replace=TRUE)
gender=sample(c(0,1),10,replace=TRUE)
#induce missingness in gender
gender[3:5]=NA
data=cbind(survival_time,dead,gender)
#do imputation
imp=mice(data)
#fit KM curves on each of the imputed datasets
km_fit=with(imp,survfit(Surv(survival_time,dead)~gender))
#now break down each km curve into male and female
#and average the surv prob at each time
#but how?
挑战在于生存时间和死亡指标始终是固定的,但每个性别的数量在插补之间发生变化。因此,每组中的数量,以及事件的数量和时间在插补之间发生变化。
假设我可以获得阶跃函数,我的计划是对阶跃函数使用应用预测来获得方法。这是最好的解决方案,还是您认为会有更好的解决方案?
为了在评论中记录答案,通过使用 summary (km_fit)
和 times
参数解决了这个问题。
我想做的是在来自 MICE 的 5 个估算数据集上拟合 5 条 Kaplan Meier 曲线。我的目标是在每个时间点取 5 个生存概率的平均值。如果我有构成每条 KM 曲线的阶跃函数的确切形式,我认为这会很容易,但我不知道如何提取它。
这是我要 运行
的代码示例#make up data
survival_time=rexp(10,3)
dead=sample(c(0,1),10,replace=TRUE)
gender=sample(c(0,1),10,replace=TRUE)
#induce missingness in gender
gender[3:5]=NA
data=cbind(survival_time,dead,gender)
#do imputation
imp=mice(data)
#fit KM curves on each of the imputed datasets
km_fit=with(imp,survfit(Surv(survival_time,dead)~gender))
#now break down each km curve into male and female
#and average the surv prob at each time
#but how?
挑战在于生存时间和死亡指标始终是固定的,但每个性别的数量在插补之间发生变化。因此,每组中的数量,以及事件的数量和时间在插补之间发生变化。
假设我可以获得阶跃函数,我的计划是对阶跃函数使用应用预测来获得方法。这是最好的解决方案,还是您认为会有更好的解决方案?
为了在评论中记录答案,通过使用 summary (km_fit)
和 times
参数解决了这个问题。