来自survreg的R中对数逻辑生存模型的预期生存时间

机器算法验证 r 生存 期望值
2022-04-08 18:16:28

我目前正在使用R apckagesurvreg中的函数估计具有对数逻辑分布的生存模型(特别是加速故障时间模型)。survival我想模拟符合 King 等人的预期生存时间。(2001),但我不确定从survreg回归输出计算对数逻辑分布的预期生存时间所需的链接函数。我在下面包含了一个最小的工作示例:

library(survival)
data(kidney)
survreg(formula = Surv(time, status) ~ 
                  age + 
                  cluster(id), 
                  data = kidney, 
                  dist = "loglogistic", 
                  robust = TRUE)

##                Value Std. Err (Naive SE)     z        p
## (Intercept)  4.38127   0.6783     0.5338  6.46 1.05e-10
## age         -0.00298   0.0135     0.0114 -0.22 8.26e-01
## Log(scale)  -0.23009   0.0732     0.1038 -3.14 1.67e-03

## Scale= 0.794 

## Log logistic distribution
## Loglik(model)= -342   Loglik(intercept only)= -342
##  Chisq= 0.07 on 1 degrees of freedom, p= 0.79 
## (Loglikelihood assumes independent observations)
## Number of Newton-Raphson Iterations: 3 
## n= 76 

我只是想知道如何根据survreg输出的估计参数计算预期生存时间。

参考文献: King, G.、Tomz, M. 和 Wittenberg, J. (2000)。充分利用统计分析:改进解释和演示。美国政治学杂志,347-361。

1个回答

似乎这更像是一个编码问题,并且可能在 StackOverflow 上得到了更及时的编码响应,但由于没有提供接近投票,我放入了一个迟来的 CV 响应。大多数 R 回归函数都有相关的predict方法,survreg 也不例外。您需要将模型调用的输出分配给命名对象,然后运行预测:

sreg.model <- .Last.value
predict(sreg.model)
#_________
 [1] 73.54492 73.54492 69.29323 69.29323 72.67421 72.67421
 [7] 72.89091 72.67421 77.59404 77.59404 76.22015 75.99355
snipped

因此,这些是原始数据集中每个协变量组合的预期值。如果您现在想要可能更适合构建绘图的预测,您将以数据框的形式提供一个 newdata 参数。请参阅?predict.survival一个工作示例。它还显示了如何绘制预期生存曲线,如果您选择了预期的 50% 生存率,您将获得预测的中值。

pct <- 1:98/100   
ptime <- predict(sreg.model, newdata=data.frame(age=10:69, id=1) , type='quantile',   p=pct, se=TRUE)
ptime$fit[ ,50]
 [1] 77.59404 77.36335 77.13335 76.90403 76.67539 76.44743
 [7] 76.22015 75.99355 75.76762 75.54236 75.31777 75.09384
[13] 74.87059 74.64800 74.42606 74.20479 73.98418 73.76422
#snipped