I am trying to obtain survival estimates for different people at a specific time.
My code is as follows:
s = Surv(outcome.[,1], outcome.[,2])
survplot= (survfit(s ~ person.list[,1]))
plot(survplot, mark.time=FALSE)
summary(survplot[1], times=4)[1]
This code creates the survival object, creates a survival curve for each 11 of the people, plots each of the curves, and with the summary function I can obtain the survival estimate for person 1 at time = 4.
I am trying to create a list of the survival estimates for each person at a specified time (time = 4).
Any help would be appreciated.
Thanks,
Matt
If all that you say is true, then this is a typical way of generating a list using indices as arguments:
If you really meant that you wanted a vector of survival estimates based at that time, then
sapplywould make an attempt to simply the result to an atomic form such as a numeric vector or a matrix in the case where the results were “multidimensional”. I would have thought that you could have gotten a useful result with just:That should have succeeded in giving you a vector of predicted survival times (assuming such times exist.) If you get too greedy and push out the ‘times’ value past where there are estimates, then you will throw an error. Ironically that error will not be thrown if there is at least one time where all levels of the covariates have an estimate. Using the example in the help page as a starting point:
Whereas if you just use 60 you get an error message: