簡體   English   中英

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

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

我目前正在查看一份說明要使用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, ...)

必須在公式部分中surv()。

有人可以告訴我surv()函數的作用嗎? 我了解它說這是一個生存對象,但是我不確定這是否是必需的。 謝謝!

在這種情況下,您只需要閱讀文檔並運行其中的示例即可。 第一個例子是? coxph ? 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) 

顯然,您需要使公式的左側/響應部分成為Surv的輸出( Surv的輸出也具有清晰的文檔;請參見?Surv )。 如果您查看該對象:

> 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"

並查看它如何反映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+

然后,要回答有關是否必要的問題,您可以嘗試在沒有它的情況下運行coxph並查看會發生什么:

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

Surv()是用於創建生存對象的函數。 為了進行生存分析,您需要跟進時間(或在時間相關變量的情況下為時間間隔)和個人狀態。 顯然,這是必需的。

您應該先閱讀生存包文檔 我還建議您閱讀這本關於生存分析的很好解釋的書: 生存分析:自學教材

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM