【问题标题】:In Survival Analysis with R, what is the purpose of the `surv`function in the Cox Proportional Hazards Model?在 R 的生存分析中,Cox 比例风险模型中“surv”函数的目的是什么?
【发布时间】:2014-08-22 05:37:40
【问题描述】:

我目前正在查看一份说明使用 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() 函数是做什么的?我知道它说它是一个生存对象,但我不确定它是否是必需的。谢谢!

【问题讨论】:

    标签: r survival-analysis


    【解决方案1】:

    在这种情况下,您只需阅读文档并运行其中的示例。 ? 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)。如果你看看那个对象:

    > 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
    

    【讨论】:

      【解决方案2】:

      Surv() 是一个创建生存对象的函数。对于生存分析,您需要后续时间(或时间间隔,如果是时间相关变量)和个人状态。显然,这是必须的。

      您应该先阅读survival package documentation。我还建议你阅读这本解释得很好的关于生存分析的书:Survival Analysis: A Self-Learning Text

      【讨论】:

        猜你喜欢
        • 2016-03-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-24
        相关资源
        最近更新 更多