楼主: moonstone
14546 3

[程序分享] R中进行生存资料AUC的计算 [推广有奖]

已卖:1872份资源

讲师

74%

还不是VIP/贵宾

-

威望
0
论坛币
10498 个
通用积分
369.1683
学术水平
160 点
热心指数
169 点
信用等级
124 点
经验
274286 点
帖子
237
精华
1
在线时间
520 小时
注册时间
2007-4-27
最后登录
2024-12-6

楼主
moonstone 发表于 2016-12-20 14:34:30 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
除了Logistic回归能够计算预测值与真实值的综合一致程度,也即AUC外,生存分析同样能计算AUC。但生存分析假设不同,生存函数的构建也就不尽相同。因而,不同方法计算得到的生存资料的AUC也不尽相同。同时,生存函数ROC曲线的绘制也更加复杂。下面提供几种常用的基于R计算生存资料AUC的方法,并提供两种时间依赖的生存函数的AUC计算示例。
但目前来说,还没有方法可以直接比较两个生存函数的AUC是否存在显著的统计学差异。

如果对R中进行生存资料分析的基础程序包不是很熟悉的话,可以先看看之前的一个帖子:
https://bbs.pinggu.org/thread-4127756-1-1.html

  1. install.packages(c("clinfun","CPE","risksetROC", "timeROC",
  2.                    "survivalROC","survC1","survIDINRI"))

  3. library(survival)

  4. set.seed(666)
  5. age <- rnorm(400, 50, 10)
  6. bp  <- rnorm(400,120, 15)
  7. d.time <- rexp(400)
  8. cens   <- runif(400,.5,2)
  9. death  <- d.time <= cens
  10. d.time <- pmin(d.time, cens)

  11. fit <- coxph(Surv(d.time,death) ~ age + bp)
  12. summary(fit)
  13. # Concordance = 0.502  (se = 0.019 )

  14. # Compute the concordance between a right-censored
  15. # survival time and a single continuous covariate
  16. survConcordance(Surv(d.time,death) ~ predict(fit))
  17. # Concordance = 0.502101  (se = 0.01883032 )
  18. # Concordance = concordant/(concordant+discordant)

  19. library(Hmisc)
  20. # Computes the c index and the corresponding generalization of
  21. # Somers' Dxy rank correlation for a censored response variable.
  22. rcorrcens(Surv(d.time,death) ~ predict(fit))
  23. # C index: 1 - 0.498 = 0.502
  24. # C index = (1+aDxy)/2 = (1+0.004)/2 = 0.502

  25. library(risksetROC)
  26. tmax <- max(d.time)
  27. # Create and plot AUC based on incident/dynamic definition of Heagerty
  28. AUC <- risksetAUC(Stime=d.time, status=death,
  29.                   marker=age + bp, method="Cox", tmax=tmax)
  30. AUC$Cindex
  31. # 0.5020833

  32. library(clinfun)
  33. # Calculate Gonen & Heller concordance probability estimate (CPE) for
  34. # for the Cox proportional hazards model.
  35. coxphCPE(fit)
  36. # CPE= 0.50884256, se.CPE = 0.01678487

  37. library(CPE)
  38. # Calculate Gonen & Heller concordance probability estimate (CPE)
  39. # for the Cox proportional hazards model.
  40. phcpe(fit, CPE.SE=TRUE,out.ties=TRUE)
  41. # CPE= 0.5088426, se.CPE = 0.01678487


  42. library(survivalROC)
  43. # Time-dependent ROC curve estimation from censored survival data
  44. AUC2 <- survivalROC(Stime=d.time, status=death,     
  45.                     marker = eta,     
  46.                     predict.time =  265, method="KM")
  47. AUC2$AUC
  48. # 0.6124465
  49. plot(AUC2$FP,
  50.      AUC2$TP,
  51.      type="l",
  52.      xlim=c(0,1), ylim=c(0,1),   
  53.      xlab=paste( "FP", "\n", "AUC = ",round(AUC2$AUC,3)),
  54.      ylab="TP",main="AUC2, Method = KM \n Year = 1")
  55. abline(0,1)

  56. library(timeROC)
  57. # Time-dependent ROC curve estimation
  58. ROC<-timeROC(T=d.time,
  59.              delta=death,
  60.              marker=eta,
  61.              other_markers=as.matrix(bp),
  62.              cause=1,
  63.              weighting="marginal",
  64.              times=quantile(d.time,probs=seq(0.2,0.8,0.1)),
  65.              ROC = TRUE,
  66.              iid = TRUE)
  67. ROC
  68. confint(ROC)
复制代码


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:AUC logistic回归 Survival logistic Packages 统计学 资料 程序

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
smm1988 + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

沙发
不如故 学生认证  发表于 2017-3-2 09:49:36
感谢楼主分享,用R survival 做COX的时候,这个C-index对应的是哪个时间点 的值呢? 默认的time=tmax吗?

藤椅
Vincent6667 发表于 2020-1-18 22:17:41
不知marker对应的“eta” 参数是什么含义,什么结构的数据?

板凳
yangming98 发表于 2020-1-18 22:40:19 来自手机
moonstone 发表于 2016-12-20 14:34
除了Logistic回归能够计算预测值与真实值的综合一致程度,也即AUC外,生存分析同样能计算AUC。但生存分析假 ...
好的好的好的好的好的好的

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 21:35