从Cox PH模型预测概率

问题描述 投票:0回答:1

我试图使用cox模型来预测一段时间后失败的概率(称为停止)3。

bladder1 <- bladder[bladder$enum < 5, ] 
coxmodel = coxph(Surv(stop, event) ~ (rx + size + number)  + 
        cluster(id), bladder1)
range(predict(coxmodel, bladder1, type = "lp"))
range(predict(coxmodel, bladder1, type = "risk"))
range(predict(coxmodel, bladder1, type = "terms"))
range(predict(coxmodel, bladder1, type = "expected"))

但是,预测函数的输出都不在0-1范围内。是否有任何功能或如何使用lp预测和基线危险函数来计算概率?

r survival-analysis cox-regression
1个回答
8
投票

请阅读predict.coxph的帮助页面。这些都不应该是概率。特定协变量集的线性预测因子是相对于假设(并且很可能不存在)情况的对数危险比,其具有所有预测值的均值。 “预期”与概率最接近,因为它是预测的事件数量,但它需要指定时间,然后除以观察开始时的风险数量。

对于predict帮助页面上提供的示例,您可以看到预测事件的总和接近实际数字:

> sum(predict(fit,type="expected"), na.rm=TRUE)
[1] 163

> sum(lung$status==2)
[1] 165

我怀疑你可能想要使用survfit函数,因为事件的概率是1概率的生存。

?survfit.coxph

类似问题的代码出现在这里:Adding column of predicted Hazard Ratio to dataframe after Cox Regression in R

由于您建议使用膀胱1数据集,因此这将是时间= 5的规范的代码

 summary(survfit(coxmodel), time=5)
#------------------
Call: survfit(formula = coxmodel)

 time n.risk n.event survival std.err lower 95% CI upper 95% CI
    5    302      26    0.928  0.0141        0.901        0.956

这将返回作为列表,生存预测作为名为$surv的列表元素:

> str(summary(survfit(coxmodel), time=5))
List of 14
 $ n       : int 340
 $ time    : num 5
 $ n.risk  : num 302
 $ n.event : num 26
 $ conf.int: num 0.95
 $ type    : chr "right"
 $ table   : Named num [1:7] 340 340 340 112 NA 51 NA
  ..- attr(*, "names")= chr [1:7] "records" "n.max" "n.start" "events" ...
 $ n.censor: num 19
 $ surv    : num 0.928
 $ std.err : num 0.0141
 $ lower   : num 0.901
 $ upper   : num 0.956
 $ cumhaz  : num 0.0744
 $ call    : language survfit(formula = coxmodel)
 - attr(*, "class")= chr "summary.survfit"
> summary(survfit(coxmodel), time=5)$surv
[1] 0.9282944
© www.soinside.com 2019 - 2024. All rights reserved.