如何在 R 中的 coxph 函数中分配偏移项,稍后可以在 "mstate" 包中使用?

How can assign an offset term in coxph function in R, which later can be used in the "mstate" package?

我正在尝试在 R 中使用 mstate 包,为此我必须使用 coxph 函数使用 strata 命令。这是一个示例代码:

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')

我只想在模型中为 transition=3(即从疾病过渡到死亡)分配一个偏移项,以便我可以通过更改偏移项来估计不同治疗效果的影响。现在,我可以通过

为所有层分配一个偏移项
mslong$c1<-0
models<-coxph(Surv(Tstart, Tstop, status) ~ strata(trans)+offset(2*c1), data=mslong, method='breslow')

我的问题是如何分配偏移项,例如,上面代码中的系数=2 仅适用于transition = 3 或strata=3?注意我打算运行下面的代码从mstate包之后。如果能提供任何帮助,我将不胜感激。

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

技术上您可以按如下方式进行:

# 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')

但是,从统计上讲这没有意义。偏移量将完全被过渡 3 的地层基线危害所掩盖。您可以验证无论偏移量如何,可能性都保持不变:

原型号:

> 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 

偏移模型:

> 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