R语言使用timeROC包计算无竞争情况下的生存资料多时间AUC值、R语言使用timeROC包可视化无竞争情况下的生存资料多时间ROC曲线

R语言使用timeROC包计算无竞争情况下的生存资料多时间AUC值、R语言使用timeROC包可视化无竞争情况下的生存资料多时间ROC曲线

目录

R语言使用timeROC包计算无竞争情况下的生存资料多时间AUC值、R语言使用timeROC包可视化无竞争情况下的生存资料多时间ROC曲线

导入包和仿真数据

R语言timeROC包timeROC函数说明

R语言使用timeROC包计算无竞争情况下的生存资料多时间AUC值(Time-dependent ROC curve estimation)

R语言使用timeROC包可视化无竞争情况下的生存资料多时间ROC曲线(Time-dependent ROC curve estimation)

导入包和仿真数据

##-------------Without competing risks-------------------
library(timeROC)
library(survival)

data(pbc)
head(pbc)
pbc<-pbc[!is.na(pbc$trt),] 0 1 # select only randomised subjects pbc$status<-as.numeric(pbc$status="=2)" create event indicator: for death, censored head(pbc) str(pbc)< code></-pbc[!is.na(pbc$trt),]>
> str(pbc)
'data.frame':   312 obs. of  20 variables:
 $ id      : int  1 2 3 4 5 6 7 8 9 10 ...

 $ time    : int  400 4500 1012 1925 1504 2503 1832 2466 2400 51 ...

 $ status  : num  1 0 1 1 0 1 0 1 1 1 ...

 $ trt     : int  1 1 1 1 2 2 2 2 1 2 ...

 $ age     : num  58.8 56.4 70.1 54.7 38.1 ...

 $ sex     : Factor w/ 2 levels "m","f": 2 2 1 2 2 2 2 2 2 2 ...

 $ ascites : int  1 0 0 0 0 0 0 0 0 1 ...

 $ hepato  : int  1 1 0 1 1 1 1 0 0 0 ...

 $ spiders : int  1 1 0 1 1 0 0 0 1 1 ...

 $ edema   : num  1 0 0.5 0.5 0 0 0 0 0 1 ...

 $ bili    : num  14.5 1.1 1.4 1.8 3.4 0.8 1 0.3 3.2 12.6 ...

 $ chol    : int  261 302 176 244 279 248 322 280 562 200 ...

 $ albumin : num  2.6 4.14 3.48 2.54 3.53 3.98 4.09 4 3.08 2.74 ...

 $ copper  : int  156 54 210 64 143 50 52 52 79 140 ...

 $ alk.phos: num  1718 7395 516 6122 671 ...

 $ ast     : num  137.9 113.5 96.1 60.6 113.2 ...

 $ trig    : int  172 88 55 92 72 63 213 189 88 143 ...

 $ platelet: int  190 221 151 183 136 NA 204 373 251 302 ...

 $ protime : num  12.2 10.6 12 10.3 10.9 11 9.7 11 11 11.5 ...

 $ stage   : int  4 3 4 4 3 3 3 3 2 4 ...

R语言timeROC包timeROC函数说明

timeROC(T, delta, marker, other_markers = NULL, cause,
        weighting = "marginal", times, ROC = TRUE, iid = FALSE)

T:事件时间

delta:事件状态. 删失数据编码为0.

marker :计算ROC的biomaker,默认是marker值越大,事件越可能发生;反之的话,前面加-号。

other_markers:矩阵形式输入,可多个marker,类似协变量. 默认值other_markers=NULL.

cause:所关心的事件结局。没有竞争风险(Without competing risks)中,必须是非删失数据的编码方式,一般为1。

存在竞争风险(With competing risks)中,和所关心的事件结局一致,通常为1 or 2.

weighting:计算方法,默认是weighting=”marginal”,KM模型;weighting=”cox” 和weighting=”aalen”分别为COX模型和additive Aalen 模型。

times:想计算的ROC曲线的时间节点。

ROC:默认值ROC = TRUE,保存sensitivities 和 specificties值。

iid: 默认值iid = FALSE。iid = TRUE 才会保存置信区间,但是样本量大了后,耗时耗资源。

R语言使用timeROC包计算无竞争情况下的生存资料多时间AUC值(Time-dependent ROC curve estimation)

评价胆红素作为一个预后的生物死亡标志物;

we evaluate bilirubin as a prognostic biomarker for death.

1) with the Kaplan-Meier estimator for computing the weights (default).

ROC.bili.marginal<-timeroc(t=pbc$time, delta="pbc$status,marker=pbc$bili," cause="1,weighting="marginal"," times="quantile(pbc$time,probs=seq(0.2,0.8,0.1))," iid="TRUE)" roc.bili.marginal< code></-timeroc(t=pbc$time,>
> ROC.bili.marginal
Time-dependent-Roc curve estimated using IPCW  (n=312, without competing risks).

         Cases Survivors Censored AUC (%)   se
t=999.2     53       249       10   83.96 2.91
t=1307.4    68       218       26   85.66 2.56
t=1839.5    86       156       70   88.03 2.25
t=2555.7   102        94      116   83.41 3.17
t=3039     108        63      141   80.79 3.48

Method used for estimating IPCW:marginal

Total computation time : 0.19  secs.

R语言使用timeROC包可视化无竞争情况下的生存资料多时间ROC曲线(Time-dependent ROC curve estimation)


plot(ROC.bili.marginal,
     time=999.2, col="red", lwd=2, title = "")   #time&#x662F;&#x65F6;&#x95F4;&#x70B9;&#xFF0C;col&#x662F;&#x7EBF;&#x6761;&#x989C;&#x8272;
plot(ROC.bili.marginal,
     time=1307.4, col="blue", add=TRUE, lwd=2)    #add&#x6307;&#x662F;&#x5426;&#x6DFB;&#x52A0;&#x5728;&#x4E0A;&#x4E00;&#x5F20;&#x56FE;&#x4E2D;
plot(ROC.bili.marginal,
     time=1839.5, col="orange", add=TRUE, lwd=2)

#&#x6DFB;&#x52A0;&#x6807;&#x7B7E;&#x4FE1;&#x606F;
legend("bottomright",
       c(paste0("AUC at 1 year: ",round(ROC.bili.marginal[["AUC"]][1],2)),
         paste0("AUC at 2 year: ",round(ROC.bili.marginal[["AUC"]][2],2)),
         paste0("AUC at 3 year: ",round(ROC.bili.marginal[["AUC"]][3],2))),
       col=c("red", "blue", "orange"),
       lty=1, lwd=2,bty = "n")

R语言使用timeROC包计算无竞争情况下的生存资料多时间AUC值、R语言使用timeROC包可视化无竞争情况下的生存资料多时间ROC曲线

安利一个R语言的优秀博主及其CSDN专栏:

博主博客地址:

博主R语言专栏地址(R语言从入门到机器学习、持续输出已经超过1000篇文章)

参考:R

参考:timeROC: Time-dependent ROC curve estimation

参考:R|timeROC-TimeDependent ROC分析

参考:R语言画多个时间点和多变量ROC曲线

参考:R语言多个时间点及多指标ROC曲线

Original: https://blog.csdn.net/sdgfbhgfj/article/details/123644742
Author: sdgfbhgfj
Title: R语言使用timeROC包计算无竞争情况下的生存资料多时间AUC值、R语言使用timeROC包可视化无竞争情况下的生存资料多时间ROC曲线

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/618801/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球