R language to implement competing risk model (1)

#竞争风险模型
tmp <- data.frame(gene = tiaoxuan[,5:6],
                  OS.Time = Train[,"Survival_months"], 
                  OS = Train[,"CSS"],
                  stringsAsFactors = F) 
colnames(tmp)
#方法1:riskregression
library(riskRegression)
fgr1<-FGR(Hist(OS.Time,OS)~gene.Cancer_directed_surgery+gene.Systemic_therapy,data = tmp,cause = 1)

#方法2:cmprsk
library(cmprsk)
help(package="cmprsk")
CIF <- cuminc(ftime = tmp$OS.Time, fstatus =tmp$OS, group = tmp$gene.Cancer_directed_surgery, cencode = 0)
CIF
vars <- tmp[, c("gene.Cancer_directed_surgery","gene.Systemic_therapy")] %>% sapply(.,as.numeric)
str(tmp)
fit <- crr(ftime=tmp$OS.Time, fstatus=tmp$OS, vars,failcode=1,cencode = 0) ##拟合模型
summary(fit)

#mstate:构建列线图
#方法1
library(mstate)
tmp$id<-1:1193
df.w <- crprep("OS.Time", "OS",
               data=tmp, trans=c(1,2),
               id="id",
               cens=0,keep=c("gene.Cancer_directed_surgery","gene.Systemic_therapy"))
df.w$Time<- df.w$Tstop - df.w$Tstart
cox <- coxph(Surv(Time,status==1)~ gene.Cancer_directed_surgery+gene.Systemic_therapy, data=df.w[df.w$failcode==1,],
           weight=weight.cens,
           subset=failcode==1) 
cox
library(regplot)
regplot(cox)
#方法2
#install.packages("QHScrnomo")
library(QHScrnomo)
help(package="QHScrnomo")
dd <- datadist(tmp)
options(datadist = "dd")
prostate.f <- cph(Surv(OS.Time,OS == 1) ~ gene.Cancer_directed_surgery+gene.Systemic_therapy,
                  data = tmp,
                  x = TRUE, y= TRUE, surv=TRUE,time.inc = 12)
prostate.crr <- crr.fit(prostate.f,cencode = 0,failcode = 1)
## make a CRR nomogram
nomogram.crr(prostate.crr,failtime = 12,lp=FALSE,
             funlabel = "Predicted 1-year cumulative incidence")

 

It is worth noting that the coefficients of the model built using crprep are similar but inconsistent with the above two methods. Anyone who knows the reason is welcome to leave a message in the comment area.

Guess you like

Origin blog.csdn.net/weixin_49320263/article/details/133501392