[英]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)?
是否有在不同尺度(例如原始时间尺度、概率)中进行操作的技巧?
示例代码或示例将不胜感激。
所有者接受的答案仅适用于 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 的存活率。
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.