搜索
人大经济论坛 附件下载

附件下载

所在主题:
文件名:  cgdModProject2013.txt
资料下载链接地址: https://bbs.pinggu.org/a-1328170.html
附件大小:

分析一个Gamma Interferon的Trial
背景见这里
http://www.nejm.org/doi/full/10.1056/NEJM199102213240801
数据里有变量 ID,Z1-Z9,T1,D
其中Z1是,T1是时间,D是event/censoring indicator
参见下面的代码里有其他变量的解释
  1. rm(list=ls())
  2. setwd(dir="c:/bios622/final")
  3. library(survival)
  4. library(MASS)

  5. #load data
  6. cgd <- read.table(file='cgdModProject2013.csv', header=T, sep=',')
  7. names(cgd)

  8. #variable labels of Z1-Z9, T1, and D
  9. #won't apply due to 'if (FALSE)'
  10. if (FALSE) {
  11. names(cgd)[c(2:12)] <- c('Treatment Code',
  12. 'Pattern of inheritance',
  13. 'Age (year)',
  14. 'Height (cm)',
  15. 'Weight (kg)',
  16. 'Using corticosteroids at time of study entry',
  17. 'Using prophylactic antibiotics at time of study entry',
  18. 'Gender',
  19. 'Hospital Category',
  20. 'Elapsed time (in days) from randomization to the diagnosis of a serious infection or censoring',
  21. 'Censoring indicator'
  22. )
  23. }

  24. #label values
  25. cgd$Z1 <- factor(cgd$Z1, levels=c(2,1), labels=c('Placebo','Gamma Interferon'))
  26. cgd$Z2 <- factor(cgd$Z2, levels=c(1,2), labels=c('X-linked','Autosomal recessive'))
  27. cgd$Z6 <- factor(cgd$Z6, levels=c(2,1), labels=c('No','Yes'))
  28. cgd$Z7 <- factor(cgd$Z7, levels=c(1,2), labels=c('Yes','No'))
  29. cgd$Z8 <- factor(cgd$Z8, levels=c(1,2), labels=c('Male','Female'))
  30. cgd$Z9 <- factor(cgd$Z9, levels=c(1,2,3,4), labels=c('US-Other','US-NIH','Europe-Amsterdam','Europe-Other'))
  31. cgd$D <- factor(cgd$D, levels=c(1,2), labels=c('Occurred', 'Censored'))

  32. #time-to-event setup
  33. survData <- Surv(time=cgd$T1, event=(cgd$D=='Occurred'))

  34. #overall
  35. summary(survData)
  36. km1 <- survfit(survData ~ 1, error="greenwood", conf.type="log-log", data=cgd)
  37. #png(file='01.overall.png', width=1200, height=960, res=144, bg='transparent')
  38. plot(km1, xlab="Survival time (days)", ylim=c(.25,1),
  39. ylab="Estimated survival probability",
  40. main="Figure 1. Overall Kaplan-Meier Estimator with pointwise CI", conf=T, mark=3, cex=0.5)
  41. #dev.off()
复制代码
我现在知道把COX PH MODEL估计的概率画到KAPLAN-MEIER曲线上
  1. kmZ1 <- survfit(survData ~ Z1, data=cgd)
  2. plot(kmZ1, xlab="Time (days)", ylab="Estimated probability of no infection", ylim=c(0,1),
  3. main="Figure 2. Kaplan-Meier Estimator with pointwise CI by Treatment", lty=1:2, mark=3, cex=0.5, col=c("red","blue"))
  4. cox1 <- coxph(survData ~ Z1+Z2, data=cgd)
  5. lines(survexp(~Z1, ratetable=cox1, data=cgd), col=c('purple', 'orange'), lty=c(3,4))
复制代码
请问
(1)如何把WEIBULLREGRESSION拟合的概率也画上去,我在网上找的代码不管用
SOLVED

  1. kmZ1 <- survfit(survData ~ Z1, data=cgd)
  2. plot(kmZ1, xlab="Time (days)", ylab="Estimated probability of no infection", ylim=c(0,1),
  3. main="Figure 2. Kaplan-Meier Estimator with pointwise CI by Treatment", lty=1:2, mark=3, cex=0.5, col=c("red","blue"))
  4. #overlay predicted survival rate by COX PH model
  5. cox1 <- coxph(survData ~ Z1+Z2, data=cgd)
  6. lines(survexp(~Z1, ratetable=cox1, data=cgd), col=c('purple', 'orange'), lty=c(3,4))
  7. #overlay predicated survival rate by Weibull regression
  8. sWei <- survreg(survData ~ Z1,dist='weibull',data=cgd)
  9. time <- predict(sWei, newdata=list(Z1=as.factor('Gamma Interferon')),type="quantile",p=seq(.01,.99,by=.01))
  10. lines(time, 1-seq(.01,.99,.01), lty=5)
  11. time <- predict(sWei, newdata=list(Z1=as.factor('Placebo')),type="quantile",p=seq(.01,.99,by=.01))
  12. lines(time, 1-seq(.01,.99,.01), lty=6)
复制代码


(2)怎样确定WEIBULL和COXPH哪个更适合这个数据?(500点)
(3)WEIBULLREGRESSION怎么检查ASSUMPTION和DIAGNOSTICS?(414点)






    熟悉论坛请点击新手指南
下载说明
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。
2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。
3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。
(如有侵权,欢迎举报)
二维码

扫码加我 拉你入群

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

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

GMT+8, 2026-1-10 08:23