I am using the time transform feature of the coxph
function in the survival
package to model the effect of a time varying covariate.
fit <- coxph(Surv(start, stop, death) ~ disease + tt(disease), data=data,
tt=function(x,t,...) x*t, x=TRUE)
My question is, can Cox-Snell residuals be computed from this model to assess goodness of fit, and if so, how? I have tried to compute them like this:
res <- data$death - fit$residual
But the problem is that the vector fit$residual
is much longer than data$death
, and I don't understand why. Shouldn't these vectors be the same length? How come there are more residuals than there are observations? I do not have this problem if I specify the time varying effect this way:
fit2 <- coxph(Surv(start, stop, death) ~ disease + disease:stop, data=data, x=TRUE)
Now I can compute Cox-Snell residuals as res <- data$death - fit$residual
.