简体   繁体   English

在使用R进行的生存分析中,考克斯比例危害模型中surv函数的目的是什么?

[英]In Survival Analysis with R, what is the purpose of the `surv`function in the Cox Proportional Hazards Model?

I am currently looking at a document that states to use the Cox Proportional Hazards model, your response variable for the formula portion of 我目前正在查看一份说明要使用Cox比例危害模型的文档,该模型是您的公式部分的响应变量

coxph(formula, data=, weights, subset, 
      na.action, init, control, 
      ties=c("efron","breslow","exact"), 
      singular.ok=TRUE, robust=FALSE, 
      model=FALSE, x=FALSE, y=TRUE, tt, method, ...)

must surv() in the formula portion. 必须在公式部分中surv()。

Can someone tell me what the surv() function does? 有人可以告诉我surv()函数的作用吗? I understand it states it is a survival object, but I am not sure if it is something that is necessarily required. 我了解它说这是一个生存对象,但是我不确定这是否是必需的。 Thanks! 谢谢!

This is a case where you need to just read the documentation and run the examples therein. 在这种情况下,您只需要阅读文档并运行其中的示例即可。 The first example in ? coxph 第一个例子是? coxph ? coxph shows the following: ? coxph显示以下内容:

# Create the simplest test data set 
test1 <- list(time=c(4,3,1,1,2,2,3), 
              status=c(1,1,1,0,1,1,0), 
              x=c(0,2,1,1,1,0,0), 
              sex=c(0,0,0,0,1,1,1)) 
# Fit a stratified model 
coxph(Surv(time, status) ~ x + strata(sex), test1) 

Clearly, you need to have the lefthandside/response part of the formula be the output from Surv (which also has clear documentation that you can read; see ?Surv ). 显然,您需要使公式的左侧/响应部分成为Surv的输出( Surv的输出也具有清晰的文档;请参见?Surv )。 If you take a look at that object: 如果您查看该对象:

> str(Surv(test1$time,test1$status))
 Surv [1:7, 1:2] 4  3  1  1+ 2  2  3+
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:2] "time" "status"
 - attr(*, "type")= chr "right"

And see how it reflects the information contained in the time and status columns: 并查看它如何反映timestatus列中包含的信息:

> with(test1, cbind.data.frame(time, status, Surv(time,status)))
  time status Surv(time, status)
1    4      1                 4 
2    3      1                 3 
3    1      1                 1 
4    1      0                 1+
5    2      1                 2 
6    2      1                 2 
7    3      0                 3+

Then, to answer your question about whether it is necessary, you can just try running coxph without it and see what happens: 然后,要回答有关是否必要的问题,您可以尝试在没有它的情况下运行coxph并查看会发生什么:

> coxph(time ~ x + strata(sex), test1) 
Error in coxph(time ~ x + strata(sex), test1) : 
  Response must be a survival object

Surv() is a function to create the survival object. Surv()是用于创建生存对象的函数。 For survival analysis you need the follow-up time (or time intervals in case of time-dependent variables) and the status of the individual. 为了进行生存分析,您需要跟进时间(或在时间相关变量的情况下为时间间隔)和个人状态。 Obviously, it is necessarily required. 显然,这是必需的。

You should read the survival package documentation first. 您应该先阅读生存包文档 I also suggest that you read this very well explained book about survival analysis: Survival Analysis: A Self-Learning Text 我还建议您阅读这本关于生存分析的很好解释的书: 生存分析:自学教材

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM