With the following sample I wish to illustrate the problem I have with estimating the survival of individuals while having time-dependent covariates in R.
I start with the standard veterans database, which I split up at 90 and 180 days (as an illustration). I proceed by creating a CPH model (from RMS) and attempt to get a prediction of the second patient with the standard survest
function at 210 days.
library("rms")
vet2 <- survSplit(Surv(time, status) ~ ., data= veteran,
cut=c(90, 180),
episode= "tgroup", id="id")
vfit2 <- cph(Surv(tstart, time, status) ~ trt + prior +
karno*strat(tgroup), data=vet2, surv = T, X=T, Y=T)
prob = survest(vfit2, newdata=vet2[vet2$id==2, ],
times=210)$surv
However this results in
2 3 4
NA NA 0.8919535
Which obviously is incorrect. First of all the NAs shouldn't be there and the probability of 0.89 is way too high. I believe that 89% probability is the chance of reaching 210 days, GIVEN that you've already reached 180. That seems to make more sense. Given this reasoning, I should then predict the survival at 90, 180 and 210 days and multiply these probabilities for the respective episodes, right?
I did this with:
prod(diag(survest(vfit2, newdata=vet2[vet2$id==2, ], times=c(90, 180, 210))$surv))
which results in a probability of 0.293
Is this algorithm/reasoning correct? Can I use this method to calculate survival probabilities with time-varying covariates?