簡體   English   中英

如何使用 survreg model 預測特定時間點的生存率?

[英]How to predict survival at certain time points, using a survreg model?

數據

library(survival)
kidney

在此處輸入圖像描述

Model

model = survreg(Surv(time, censored) ~ sex + age, data = kidney)

Call:
survreg(formula = Surv(time, censored) ~ sex + age, data = kidney)

Coefficients:
(Intercept)   sexfemale         age 
 8.44411429 -0.89481679 -0.02170266 

Scale= 1.653512 

Loglik(model)= -122.1   Loglik(intercept only)= -122.7
    Chisq= 1.21 on 2 degrees of freedom, p= 0.547 
n= 76 

如何預測多個時間點(例如 30、90、182 天)的兩性存活率(加上 95% CI)?

是否有在不同尺度(例如原始時間尺度、概率)中進行操作的技巧?

示例代碼或示例將不勝感激。

您可以使用survminer package。 例子:

library(survival)
library(survminer)

f1 <- survfit(Surv(time, status) ~ sex, data = kidney)

res.sum <- surv_summary(f1, data = kidney)

# define desired time points
times <- c(30, 90, 182)

summary(f1,times)

在此處輸入圖像描述

所有者接受的答案僅適用於 Kaplan-Meier 估計器,它不是參數生存 model (AFT)。 OP 詢問如何從survreg中的 survreg object 預測存活率。 我有一個類似的問題:給定事件的離散時間,如何從 Weibull model 預測存活率?

survival predict.survreg中的 predict.survreg function 不能預測給定事件離散時間(t = 1、2、3、...、48)的生存率(概率)。 幸運的是,對於 Weibull AFT 模型,我們可以使用pweibull function 或累積風險 function 來預測給定 t 的存活率。

方法一:pweibull()

library(survival)

model = survreg(Surv(time, status) ~ sex + age, data = kidney,
                dist="weibull")

time_days = c(30, 90, 182)

newdat <- data.frame(sex=1, age=44)

mu_hat <- predict(model, newdata=newdat, type="link")

surv_hat <- 1 - pweibull(time_days, 
                         shape=1/model$scale,
                         scale=exp(mu_hat))

surv_hat

方法二:累積風險

predict_survival_weibull <- function(object, newdata, t){
  mu_hat <- predict(object, newdata=newdata, type="link")
  
  cum_hazard <- (t / exp(mu_hat))^(1/object$scale)
  
  surv <- exp(-cum_hazard)
  
  return(surv)
}

predict_survival_weibull(model, newdat, t=time_days)

暫無
暫無

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

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