I am trying to fit a multi-state model using the coxph
function from the survival
package in R and I want to perform some model diagnostics. I can use the following code to fit an example of a multi-state model:
require(mstate)
require(survival)
data(ebmt3, package = "mstate")
temp = subset(ebmt3, select = -c(prtime, prstat, rfstime, rfsstat))
edata = tmerge(
temp,
ebmt3,
id,
rstat = event(rfstime, rfsstat),
pstat = event(prtime, prstat),
priorpr = tdc(prtime)
)
edata$event = with(edata, factor(pstat+2*rstat,0:2,labels=c("censor","PR","RelDeath")))
levels(edata$drmatch) = c("match","mismatch")
efit1 = coxph(Surv(tstart, tstop, event) ~ dissub+age+drmatch+tcd,id=id,data=edata,ties="breslow")
This gives three models for the $1 \to 2$, $1 \to 3$, and $2 \to 3$ transitions. From my understanding, each model for the transition $i \to j$ should (1) satisfy the proportional hazards assumption and (2) satisfy the Markov property, and I should also check for (3) influential points and (4) linearity. In a standard $\text{alive} \to \text{death}$ survival analysis model I'd check (1) using cox.zph
, (3) using the dfbeta residuals and (4) by making plots of the martingale residuals from the null model against the predictors I'm interesting in using.
My questions then are:
- Is there a simple way to do this within the
survival
package for a multi-state model, or a way to extract the individual models to perform the required analyses? When trying to useresiduals(efit1, type = "martingale")
the length of the resulting vector is greater than the number of observations in the original data, and thecollapse
argument inresiduals.coxph
is not clear. Similarly, usingresiduals(efit1, type = "dfbetas")
says that theresiduals method for multistate coxph objects is incomplete
. Usingcox.zph
seems to work but it would be nicer to apply onto the individual models. - Is there a way within the
survival
package to perform a hypothesis test for the Markov property? There's the functionMarkovTest
from themstate
package, but that's only for models built with themstate
functions rather thancoxph
.