library(survival)
data(pbc)
fit <- prodlim(Hist(time,status)~1,data=pbc)
## predict the survival probs at selected times
predict(fit,times=c(10,100,1000))
## works also outside the usual range of the Kaplan-Meier
predict(fit,times=c(-1,0,10,100,1000,10000))
## newdata is required if there are strata
## or neighborhoods (ie overlapping strata)
mfit <- prodlim(Hist(time,status)~edema+age,data=pbc)
predict(mfit,times=c(-1,0,10,100,1000,10000),newdata=pbc[18:21,])
## this can be requested in matrix form
predict(mfit,times=c(-1,0,10,100,1000,10000),newdata=pbc[18:21,],mode="matrix")
## and even transposed
predict(mfit,times=c(-1,0,10,100,1000,10000),newdata=pbc[18:21,],mode="matrix",bytime=TRUE)
Run the code above in your browser using DataLab