问题描述
我有以下survreg模型:
I have the following survreg model:
Call:
survreg(formula = Surv(time = (ev.time), event = ev) ~ age,
data = my.data, dist = "weib")
Value Std. Error z p
(Intercept) 4.0961 0.5566 7.36 1.86e-13
age 0.0388 0.0133 2.91 3.60e-03
Log(scale) 0.1421 0.1208 1.18 2.39e-01
Scale= 1.15
Weibull distribution
我想根据上述估算值绘制危险函数和生存率函数.
我不想使用predict()
或pweibull()
(如此处参数生存或此处.
I would like to plot the hazard function and the survival function based on the above estimates.
I don't want to use predict()
or pweibull()
(as presented here Parametric Survival or here SO question.
我想使用curve()
函数.有什么想法我可以做到这一点吗? survreg的Weibull函数似乎使用了比平常其他的比例和形状定义(例如rweibull不同).
I would like to use the curve()
function. Any ideas how I can accomplish this? It seems the Weibull function of the survreg uses other definitions of scale and shape than the usual (and different that for example rweibull).
更新:我想我真正需要它来表达危险/生存的函数是估计值Intercept
,age (+ other potential covariates)
,Scale
的函数,而不使用任何现成的*weilbull
函数.
UPDATE: I guess what I really require it to express hazard / survival as a function of the estimates Intercept
, age (+ other potential covariates)
, Scale
without using any ready made *weilbull
function.
推荐答案
您的参数是:
scale=exp(Intercept+beta*x)
,假设年龄为40岁
scale=283.7
您的形状参数是模型输出的比例的倒数
your shape parameter is the reciprocal of the scale that the model outputs
shape=1/1.15
那么危险是:
curve((shape/scale)*(x/scale)^(shape-1), from=0,to=12,ylab=expression(hat(h)(t)), col="darkblue",xlab="t", lwd=5)
累积危害函数为:
curve((x/scale)^(shape), from=0,to=12,ylab=expression(hat(F)(t)), col="darkgreen",xlab="t", lwd=5)
生存函数是1-累积危害函数,因此:
The Survival function is 1-the cumulative hazard function, so:
curve(1-((x/scale)^(shape)), from=0,to=12,ylab=expression(hat(S)(t)), col="darkred",xlab="t", lwd=5, ylim=c(0,1))
还要检出eha
软件包以及功能hweibull
和Hweibull
Also check out the eha
package, and the function hweibull
and Hweibull
这篇关于使用curve()绘制Survreg的生存率和危险函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!