What I am trying to do is to fit 5 Kaplan Meier curves on 5 imputed datasets from MICE. What I aim to do is at every time point, take the average of the 5 survival probabilities. I think this would be easy if I had the exact form of the step function that makes up each of the KM curves, but I don't know how to extract that.
Here is an example of the code that I would run
#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?
The challenge is that the survival time and death indicator are always fixed, but the amount in each gender changes between imputation. Because of this, the number in each group, and thus the number and time of events changes between imputation.
What my plan would be, supposing I could get the step functions would be to use apply predict on the step functions to get the means. Is this the best solution, or do you think there would be a better one?
To record the answer in the comments, this was resolved by using summary (km_fit)
with the times
argument.