It is easy to get a cumulative hazard curve.
First, decide what values of "age", "a", and "b" you want curves for

  tdata<- data.frame(age=55, a=2, b=6)

Get the curves, there will be one for each strata in the output
  sfit<- survfit(coxPhMod, newdata= tdata)

Plot them
  plot(sfit, fun='cumhaz', col=1:4, xlab= etc etc)

Hazard functions are something else again, estimating these rigorously is
akin to density estimation.  A quick and dirty method is to use smooth.spline.
   temp<- sfit[1]  #grab the first curve
   tfit<- smooth.spline(temp$time, -log(temp$surv), df= 5) #smooth the cum haz
   plot(predict(tfit, deriv=1))

That value of "df=5" is made up -- you need to decide for yourself how much 
smoothing to do.
I make no claims that this is statistically well grounded, it's just a good way 
to get
a quick idea.

PS; There is no such thing as "THE" baseline hazard function; predictions are 
always for some particular value of the covariates.  In a book it is sometimes useful to 
pick a particular set of x values as a default in order to simplify notation, often x=0, 
and label that as a baseline.  But in actual computation all zeros is usually crazy 
(age=0, weight=0, blood pressure=0, etc).

Terry Therneau



Hi,
I'm going crazy trying to plot a quite simple graph.
i need to plot estimated hazard rate from a cox model.
supposing the model i like this:
coxPhMod=coxph(Surv(TIME, EV) ~ AGE+A+B+strata(C) data=data)
with 4 level for C.
how can i obtain a graph with 4 estimated (better smoothed) hazard curve
(base-line hazard + 3 proportional) to highlight the effect of C.
thanks!!
laudan

______________________________________________
R-help@r-project.org 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.

Reply via email to