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? 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.
how to plot hazard function for coxph model?
3 messages · suman kumar, David Winsemius, Suman Pramanik
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.
No, this is not what i wanted. Plotting of survfit object in therneu's survival package plots survival/cumulative incidence and cumulative hazard function for a given fit. What I wanted to know was that is there a way to plot hazard function of a plot? I got the reply from Dr Therneu yesterday. Plotting hazard is just like plotting density function. muhaz package has got the routines for doing the same. Thanks a Lot for replying. Suman On 27 July 2012 14:02, David Winsemius [via R]
<ml-node+s789695n4638070h21 at n4.nabble.com> wrote:
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.
______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ________________________________ If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/how-to-plot-hazard-function-for-coxph-model-tp4637953p4638070.html To unsubscribe from how to plot hazard function for coxph model?, click here. NAML