1

I am trying to use mstate package in R, for which I have to use coxph function using strata command. Here is a sample code:

library(mstate)
tmat <- trans.illdeath()
tg <- data.frame(stt=rep(0,6),sts=rep(0,6), illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1),
             dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1))
tg$patid <- factor(2:7,levels=1:8,labels=as.character(1:8))
tt <- matrix(c(rep(NA,6),tg$illt,tg$dt),6,3)
st <- matrix(c(rep(NA,6),tg$ills,tg$ds),6,3)
mslong<-msprep(time=tt,status=st,trans=tmat)
models <- coxph(Surv(Tstart, Tstop, status) ~ strata(trans), data=mslong, method='breslow')

I would like to assign an offset term only in the model for transition=3 (i.e. transition from illness to death) so that I can estimate the impact of different treatment effects by changing the offset term. Now, I can assign an offset term for all strata by

mslong$c1<-0
models<-coxph(Surv(Tstart, Tstop, status) ~ strata(trans)+offset(2*c1), data=mslong, method='breslow')

My question is how I can assign an offset term, for example, with coefficient=2 in the above code only for transition = 3 or strata=3? Note that I plan to run the following code from mstate package after. I would really appreciate any help on this.

fit <- msfit(models, trans=tmat)
pt <- probtrans(fit, predt=0)
4

1 回答 1

1

You can technically do it as follows:

# define c1 as an indicator for transition 3
mslong$c1<-ifelse(mslong$trans == 3, 1, 0)
model <-coxph(Surv(Tstart, Tstop, status) ~ strata(trans)+offset(2*c1), data=mslong, method='breslow')

However, statistically this does not make sense. The offset will be completely masked by the strata baseline hazard for transition 3. You can verify that regardless of offset, the likelihood remains the same:

Original model:

> coxph(Surv(Tstart, Tstop, status) ~ strata(trans), data=mslong, method='breslow')
Call:  coxph(formula = Surv(Tstart, Tstop, status) ~ strata(trans), 
    data = mslong, method = "breslow")

Null model
  log likelihood= -7.742402 
  n= 16 

Offset model:

> coxph(Surv(Tstart, Tstop, status) ~ strata(trans)+offset(2*c1), data=mslong, method='breslow')
Call:  coxph(formula = Surv(Tstart, Tstop, status) ~ strata(trans) + 
    offset(2 * c1), data = mslong, method = "breslow")

Null model
  log likelihood= -7.742402 
  n= 16 
于 2019-05-08T22:26:45.280 回答