本人做食管癌二次原发肿瘤危险因素分析。食管癌后发生第二次肿瘤为结局事件(1),未发生肿瘤前死亡未竞争事件(2),存活为(0)。
##竞争风险模型
install.packages("mstate")
library(mstate)
##进行加权
mydata<-read.csv("test.csv")
mydata$id<-1:nrow(mydata) ##给数据加上id号
df.w <- crprep("SM", "status",
data=mydata, trans=c(1,2),
cens=0,
keep=c("Race","Year","Age","PS","HT","Grade","T","N","M","CAN","S","R","C","Sex"))##进行加权数据集的构建,SM为随访事件,status为结局变量,keep为协变量数据集。
df.w$t<- df.w$Tstop - df.w$Tstart
m.crr<- coxph(Surv(t,status==1)~Year+Age+PS+Grade+T+N+M+CAN+S+R,
data=df.w,
weight=weight.cens,
subset=failcode==1)###进行加权后的竞争风险模型构建
summary(m.crr) ###结果显示
```r
Call:
coxph(formula = Surv(t, status == 1) ~ Year + Age + PS + Grade +
T + N + M + CAN + S + R, data = df.w, weights = weight.cens,
subset = failcode == 1)
n= 497589, number of events= 499
coef exp(coef) se(coef) robust se z Pr(>|z|)
Year2 -0.15911 0.85290 0.11458 0.11409 -1.395 0.16314
Year3 -0.34380 0.70907 0.12119 0.12258 -2.805 0.00503 **
Year4 -0.87798 0.41562 0.14770 0.14756 -5.950 2.68e-09 ***
Age2 0.52448 1.68958 0.21715 0.21552 2.434 0.01495 *
Age3 0.37453 1.45431 0.22474 0.22475 1.666 0.09563 .
PS2 -0.47596 0.62129 0.18161 0.17941 -2.653 0.00798 **
PS3 -0.43670 0.64616 0.16261 0.15719 -2.778 0.00547 **
PS4 -0.42893 0.65120 0.27441 0.27260 -1.573 0.11560
Grade2 -0.16557 0.84741 0.15757 0.15665 -1.057 0.29052
Grade3 -0.39688 0.67241 0.16357 0.16022 -2.477 0.01325 *
Grade4 0.48006 1.61617 0.30432 0.29125 1.648 0.09930 .
T2 0.35596 1.42755 0.20076 0.19344 1.840 0.06574 .
T3 0.01018 1.01023 0.18706 0.18058 0.056 0.95504
T4 -0.56189 0.57013 0.25026 0.25076 -2.241 0.02504 *
N1 -0.23053 0.79411 0.14199 0.13662 -1.687 0.09152 .
M1 -3.16033 0.04241 0.72557 0.68001 -4.647 3.36e-06 ***
CAN2 -0.51927 0.59496 0.19909 0.18696 -2.777 0.00548 **
CAN3 -0.38830 0.67821 0.27571 0.26714 -1.454 0.14608
CAN4 2.02960 7.61103 0.72845 0.70213 2.891 0.00384 **
S1 0.53971 1.71551 0.58622 0.54815 0.985 0.32481
S2 0.87189 2.39144 0.19247 0.18695 4.664 3.10e-06 ***
S3 0.58228 1.79011 0.22850 0.22340 2.606 0.00915 **
S4 0.62695 1.87190 0.27401 0.27034 2.319 0.02039 *
S5 0.89105 2.43770 0.13935 0.12863 6.927 4.28e-12 ***
R1 -0.15107 0.85979 0.15010 0.14510 -1.041 0.29781
R2 0.30644 1.35857 0.11767 0.10486 2.922 0.00347 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
exp(coef) exp(-coef) lower .95 upper .95
Year2 0.85290 1.1725 0.68200 1.0666
Year3 0.70907 1.4103 0.55764 0.9016
Year4 0.41562 2.4060 0.31124 0.5550
Age2 1.68958 0.5919 1.10746 2.5777
Age3 1.45431 0.6876 0.93615 2.2593
PS2 0.62129 1.6096 0.43710 0.8831
PS3 0.64616 1.5476 0.47484 0.8793
PS4 0.65120 1.5356 0.38166 1.1111
Grade2 0.84741 1.1801 0.62338 1.1519
Grade3 0.67241 1.4872 0.49120 0.9205
Grade4 1.61617 0.6187 0.91321 2.8602
T2 1.42755 0.7005 0.97709 2.0857
T3 1.01023 0.9899 0.70911 1.4392
T4 0.57013 1.7540 0.34876 0.9320
N1 0.79411 1.2593 0.60756 1.0379
M1 0.04241 23.5784 0.01119 0.1608
CAN2 0.59496 1.6808 0.41243 0.8583
CAN3 0.67821 1.4745 0.40177 1.1449
CAN4 7.61103 0.1314 1.92217 30.1366
S1 1.71551 0.5829 0.58588 5.0232
S2 2.39144 0.4182 1.65779 3.4498
S3 1.79011 0.5586 1.15538 2.7735
S4 1.87190 0.5342 1.10197 3.1798
S5 2.43770 0.4102 1.89450 3.1367
R1 0.85979 1.1631 0.64697 1.1426
R2 1.35857 0.7361 1.10619 1.6685
Concordance= 0.68 (se = 0.022 )
Likelihood ratio test= 330.7 on 26 df, p=<2e-16
Wald test = 340.9 on 26 df, p=<2e-16
Score (logrank) test = 351.4 on 26 df, p=<2e-16, Robust = 250.4 p=<2e-16
(Note: the likelihood ratio and score tests assume independence of
observations within a cluster, the Wald and robust score tests do not).
然后进行列线图绘制,但就是该步骤出现了极其困难的问题
```r
library(regplot)
nom1<-regplot(m.crr, clickable=TRUE,
points=TRUE, rank="sd",failtime = c(12,36,120),prfail = T)
结果显示
Regression m.crr coxph formula:
Surv(t, status == 1) `~` Year + Age + PS + Grade + T + N + M + CAN + S + R
Replicate integer weights assumed
Note: non-integer weights have been floored
Data has 560303 rows. Data used in fitting has 497589 rows
Data and fitted data nrow mis-match not supported
始终无法显示出图形
但如果不使用加权数据集,
m.cph<-coxph(Surv(SM,status==1)~Year+Age+PS+Grade+T+N+M+CAN+S+R,
data=mydata)
nom1<-regplot(m.crr, clickable=TRUE,
points=TRUE, rank="sd",failtime = c(12,36,120),prfail = T)
上述代码列线图则绘制成功
```r
你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答
本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。
因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。