[R] hazard function in a Cox model
Terry Therneau
therneau at mayo.edu
Mon Mar 16 13:25:59 CET 2009
-- begin included message ---
I am hoping for some advice regarding obtaining the values for the
hazard function in a cox regression that I have undertaken. I have a
model in the following form, analysed with the package survival (v.
2.34-1) and a log-log plot obtained using Design (v. 2.1-2).
For two variables, the lines in the survival curves crossed. The
statistician I been obtaining advice from (who does not use R) asked
me to obtain the hazard function values. I am wanting to confirm
whether basehaz is the correct command to obtain such values, to
better understand what is occurring in the log plots.
--- end inclusion ----
The best tool for understanding what is happening is cox.zph.
cox.V <- coxph(Surv(intDaysUntilFVPO, Event_v) ~ intAgeAtMHCIndex +
PRE + group + MHC + strGender, data = recidivismv)
zpfit <- cox.zph(cox.V, transform='identity')
plot( zpfitp[1]) #plot for the first variable
plot( zpfitp[2]) #plot for the second
You will get a plot of beta(t) versus time, a horizontal line corresponds to a
constant hazard ratio. The Cox model coefficient is an "average" of the curve,
e.g., the best horizontal line fit to it.
Other than this, you can get the predicted cumulative hazard for any
particular choice of covariates, the derivative of this = hazard and requires
some form of smoothing.
Terry Therneau
More information about the R-help
mailing list