来自 R 的 Weibull 比例风险模型的预测predict.survreg()
不是预期的生存时间。请帮助我理解这种行为。
对于时间,威布尔密度在 的参数化中由下式给出dweibull()
具有形状和比例。它的期望是。对于具有比例的 Weibull 比例风险模型,其中是协变量和系数,密度为
这可以被认为是另一个具有形状和尺度的 Weibull 密度。因此,它的期望是。我希望输出这个值,但是省略了 gamma 函数的乘法。predict.survreg()
最小工作示例:
require(survival)
require(data.table)
dt <- data.table("covariate" = c(1,2,3), "time" = c(3,5,6))
Weibull <- survreg(Surv(dt$time) ~ dt$covariate, dist = "weibull")
a <- 1 / Weibull$scale # Transform survreg() scale to dweibull() shape.
b <- exp(Weibull$coefficients[1]) # Transform survreg() intercept to dweibull() scale.
C <- - Weibull$coefficients[2] / Weibull$scale # Transform survreg() coefficients (accelerated failure time) to proportional hazard coefficients.
# This is the expectation of the Weibull proportional hazards density.
b * exp(- dt$covariate * C / a) * gamma(1 + 1/a)
# [1] 3.171904 4.485750 6.343808
# This is what predict.survreg() outputs, verified in the predict.survreg() method.
# Notice there is no gamma() function.
b * exp(- dt$covariate * C / a)
# [1] 3.301424 4.668919 6.602849
# This the predict.survreg() call, which indeed returns the same values.
as.numeric(predict(Weibull, data.table(dt$covariate)))
# [1] 3.301424 4.668919 6.602849
我很困惑,因为对生存时间的明智预测将是它的期望,这需要伽马函数。我错过了什么?