1 / 8
文档名称:

用R作生存分析.doc

格式:doc   大小:18KB   页数:8页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

用R作生存分析.doc

上传人:wz_198614 2017/10/14 文件大小:18 KB

下载得到文件列表

用R作生存分析.doc

文档介绍

文档介绍:用R作生存分析
生存分析
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)
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)
? <- Surv(age, age+time, death)
?
[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
#计算生存曲线:survfit,有三个重要的参数:formula, , and .
survfit(formula, = , = "log")
=”