用R作生存分析.doc

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
用R作生存分析

生存分析 一.Libraries and data sets library() # 查看你的系统中所有已装的libraries library(survival) # 加载一个library, 也可使用鼠标来做 library(help=survival) # see the list of available functions and data sets. data(aml) # 加载数据 aml aml # see the data # 《生存分析》需要的两个 libraries library(survival) library(KMsurv) #包含我们教材中所有的数据 # 若想使数据中的变量能够在R中作为一个变量使用,use attach(): attach(aids) infect detach(aids) 二.Survival Objects #由函数 Surv 产生一个 survival object Surv (time, time2, event, type) time: survival time time2: ending time if it is interval censored event: censoring variable. For interval censored data, 0=right censored, 1=event at time, 2=left censored, 3=interval censored. type: indicating whether it is right censored, left censored or interval censored or counting process. 默认值是右删失或 counting process #假设一个观测值为 [2, 3],则 R 语句为 Surv(time=2,time2=3, event=3, type = interval) #右删失数据 attach(aml) Surv(time,status) detach(aml) #左截断右删失数据 data(psych) attach(psych) my.surv.object - Surv(age, age+time, death) my.surv.object [1] (51,52 ] (58,59 ] (55,57 ] (28,50 ] (21,51+] (19,47 ] (25,57 ] [22] (29,63+] (35,65+] (32,67 ] (36,76 ] (32,71+] detach(psych) 三. The Kaplan-Meier Estimates #计算生存曲线:survfitformula, conf.int, and conf.type. survfit(formula, conf.int = 0.95, conf.type = log) conf.type=”plain” #linear confidence interval in our book conf.type=”log” # 对H(t)作log transformation conf.type=”log-log” #log-transformed in our book myfit = survfit(Surv(time,status) ~ 1,data=kidney) #在新版的R里,这个~1是必要的。 attach(kidney) myfit = survfit(Surv(time,status) ~ 1) #在新版的R里,这个~1是必要的。 a=summary

文档评论(0)

haihang2017 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档