[R] how to plot hazard function for coxph model?

David Winsemius dwinsemius at comcast.net
Fri Jul 27 10:30:41 CEST 2012


On Jul 26, 2012, at 9:00 AM, suman kumar wrote:

> Dear all,
>
> I have been trying to plot hazard function in R for survival data,  
> but in
> vain.
> Can anybody help me out in plotting hazard function in R?

I'm thinking this might not be what you want, although it is one  
plausible guess at what you are asking for. You really should say what  
code and data was being used. This uses a built-n dataset in  
Therneau's survival package:

fit <- coxph(Surv(time, status) ~ age + ph.ecog + strata(inst), lung)
plot( predict(fit,
               newdata=data.frame(age=62,
                                  ph.ecog=1,
                                  inst=12,
                                  time=seq(0,1000,by=100),
                 type="lp")) )

(Returns a flat line at 0.17.  Be sure to read predict.coxph carefully.)

David.

>
> Dr Suman Kumar
>
> --
> View this message in context: http://r.789695.n4.nabble.com/how-to-plot-hazard-function-for-coxph-model-tp4637953.html
> Sent from the R help mailing list archive at Nabble.com.
>



More information about the R-help mailing list