In my practical projects, I usually track a group of people for a few months, then I run a model based on the first few months behavior. Hopefully I can predict both overall and individual level's event rate in future time.
Here I will use PBC data example to illustrate my question.
library(pbc) temp <- subset(pbc, id <= 312, select=c(id:sex, stage)) # baseline pbc2 <- tmerge(temp, temp, id=id, death = event(time, status)) #set range pbc2 <- tmerge(pbc2, pbcseq, id=id, ascites = tdc(day, ascites), bili = tdc(day, bili), albumin = tdc(day, albumin), protime = tdc(day, protime), alk.phos = tdc(day, alk.phos))
I separate date into training set and test set. I use train data to build model then use test set for prediction.
pbc.train=pbc2[(1:995),] pbc.test=pbc2[(996:1807),] fit2 <- coxph(Surv(tstart, tstop, death==2) ~ log(bili) + log(protime)+age+trt, pbc.train)
Here are my questions related to prediction:
If I want to see the overall survival rate at each time point already occurred, I can use
But if I want to predict the overall survival rate at a time point not happened yet, for example at time=10000. How can I do it? summary(survfit(fit2),time=10000) will not do.
How to predict each individual's survival rate in future? I can use the predict call to compute relative hazard ratio to average for a set of covariates as follows.
covs=data.frame(bili=1.9, protime=12, age=40, trt=1) predict(fit2, newdata=covs, type="risk")
But the real test data is organized as one person has multiple records. More importantly, for each individual, time dependent covariates changes at each time interval. Therefore, if I used something like
It does not make sense. I want to know each person's risk of death in future or at each future time points. How can I do that?
another side question, in the test data, some people are already died. Is that appropriate that I delete the ids who already have event happened? Only use predict model to predict the future survival rate for patients survived from this study.