# [R] Hazard curves

Terry Therneau therneau at mayo.edu
Tue Sep 30 15:47:32 CEST 2008

```-- begin included message -----
I am looking at a continuous variable, age.  I am looking at time to
12-month remission and can calculate the HR and 95% confidence interval are
follows:
coxfita = coxph(Surv(rem.Remtime,rem.Rcens)~nearma\$all.age,data=nearma)
exp(coxfita\$coefficients)
exp(confint(coxfita))

However, because I am looking at age as a continuous variable I cannot draw
a Kaplan-Meier curve.  Instead I need to draw a plot of hazard against age.
How do I do this? I don't think
plot(nearma\$all.age,coxfita\$linear.predictors) is quite right.

Laura

--- End included

There is not a simple plot: hazard is a function of both time and age, so will
be a 2-d surface.
A common plan is to plot the predicted survival for a small set of ages.

ageset <- c( 40, 55, 70)
curves <- survfit(coxfita, newdata= data.frame(all.age = ageset))
plot(curves, col=1:3)

This will give a plot with 3 predicted survival curves, for ages 40, 55 and 70.

The plot of hazard vs age at any particular time point is not very
interesting: it will be h(t, age) = k exp(coefficient * age).  This does not
reflect the data in any way, just your decision that age would be a linear term
in the model.  If you want to explore the effect of age, then fit the