I have many observations of data, and survival ranges from month1 to month24. i.e some patients will survive 1month, 2month, 3month, or go all the way to month24. For each observation, I'm trying to get monthly predictions, up to month24.
A cox-ph output may show something like the table below [![enter image description here][1]][1]
However, this analysis has time dependent covariate where the there's a change every 12 month mark. To address this, I reformated my data to tstart tstop format, and now, my survival rate looks like this after I fit the cox model again
ph<- tmerge(data, data, id=observation, tstart=0, tstop=survived_through)
I guess ID observation 1 makes sense since I see gradually decreasing probabilities of survival.
Observation 2 is where I'm having issues. From month1 to month12, I still see gradually decreasing probabilities, but from month 12-24, it "resets" to 96% survival. It appears as if it is treating each row of observation 2 as different observations. How would I go about "connecting" observation 2 so it will show decreasing probabilities from 0 to 24?
Is it reasonable to say that the probabilities from 0 to 12 of tstart/tstop[0-12] is correct, and the probability of 12 to 24 of tstart/tstop[12-24] is the 'adjusted probability' after adding the time varying covariate (and it is also accounting for the time varying covariate from 0 to 12) and I can just "chain them" together?
I'm using R and the survival package.
EDIT: TOY EXAMPLE FOR REFERENCE (DIFFERENT FROM THE TABLE ABOVE)
#CREATE DATAFRAME (TIME VARYING IS ALREADY CODED)
df <- data.frame("id" = c(1,2,2,3,3,3), "gender" = c("m","f","f","m","m","m"), "time0" = c(0,0,1,0,5,8), "time1" = c(1,1,4,5,8,10), "death" = c(1,0,1,0,0,1))
#CREATE SURVIVE OBJECT
surv_object1 <- Surv(time=df$time0, time2 = df$time1, event = df$death)
#COX MODEL
fit.cox <- coxph(surv_object1 ~gender, data = df)
#PREDICT
results<- survfit(fit.cox, newdata=df)
summary(results)
scoring the data to get the predicted probabilities, I get survival1...survival2...survival6 denoting each observation, but you see the estimate don't gradually decline from survival2 to survival3(survival2 and survival3 are still the same observation just at different time points)
EDIT 2:
Sorry. I think you can ignore my original table. That was used just for illustrative purposes. Here's an extension of the toy example w/ time covariates. "tdc" is the time varying covariate that happens every 12 months.
library(survival)
#CREATE DATAFRAME (TIME VARYING IS ALREADY CODED)
df <- data.frame("id" = c(1,2,2,3,3,3), "gender" = c("m","f","f","m","m","m"),
"time0" = c(0,0,12,0,24,36),
"time1" = c(1,12,24,24,36,48), "death" = c(1,0,1,0,0,1),
"tdc" = c(1.2,1.0,1.2,2.1,1.4,1.6))
surv_object1 <- Surv(time=df$time0, time2 = df$time1, event = df$death)
#COX MODEL
fit.cox <- coxph(surv_object1 ~tdc, data = df)
#PREDICT
results<- survfit(fit.cox, newdata=df)
summary(results)
```
predict()
function applied to your model, and I suspect that the problem is in how that particular function is being invoked. $\endgroup$survival2
andsurvival3
represent the sameindividual2
with the same covariate, so the survival predictions at event times are necessarily the same for that individual. Also, the tables produced by your example seems to present different information from the tables that were in a previous version of the question. So it's still hard to see what your specific question is. $\endgroup$