Plot survival and hazard function of survreg using curve()

前端 未结 2 1124
北荒
北荒 2021-02-05 21:20

I have the following survreg model:

Call:
survreg(formula = Surv(time = (ev.time), event = ev) ~ age, 
    data = my.data, dist = \"weib\")
             Value S         


        
2条回答
  •  没有蜡笔的小新
    2021-02-05 21:32

    Your parameters are:

    scale=exp(Intercept+beta*x) in your example and lets say for age=40

    scale=283.7
    

    your shape parameter is the reciprocal of the scale that the model outputs

    shape=1/1.15
    

    Then the hazard is:

    curve((shape/scale)*(x/scale)^(shape-1), from=0,to=12,ylab=expression(hat(h)(t)), col="darkblue",xlab="t", lwd=5)
    

    The cumulative hazard function is:

    curve((x/scale)^(shape), from=0,to=12,ylab=expression(hat(F)(t)), col="darkgreen",xlab="t", lwd=5)
    

    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))
    

    Also check out the eha package, and the function hweibull and Hweibull

    Weibull Functions

提交回复
热议问题