My question is, how to compute hazard function(H(t)) after building the coxph model. I even aware of the terminology that differs from hazard function(H(t)) and the hazard rate(h(t)). Here onward I wish to calculate both.
Here what I have done in two different methods; ########################################################################################## ########################################################################################## Method - 1 # Coxph Model ## MODEL.COXPH <- coxph(Surv(time,status) ~ X1+X2 , data = MyData) ########################################################################################## ########################################################################################## # Survfit for the coxph object ## MODEL.COXPH.SURVFIT <- survfit(MODEL.COXPH) # Obtaining the object "surv" from the survfit object MODEL.COXPH.SURVFIT.SURV <- MODEL.COXPH.SURVFIT$surv # Computing the hazard function ## ## I am pretty confuse in this; whether result from this, is a hazard function(H(t)) or baseline cumulative hazard function(H_0(t)) ## Hazard.Function <- -log(MODEL.COXPH.SURVFIT.SURV) ################################################ ################################################ # Baseline hazard function can also be calculated explicitly ## MODEL.COXPH.BASELINEHAZ <- basehaz(MODEL.COXPH) ########################################################################################## ########################################################################################## ########################################################################################## ########################################################################################## Method - 2 # Coxph Model ## MODEL.COXPH <- coxph(Surv(time,status) ~ X1+X2 , data = MyData) ########################################################################################## ########################################################################################## # Survfit for the coxph object ## MODEL.COXPH.SURVFIT <- survfit(MODEL.COXPH) ########################################################################################## ########################################################################################## # Proportion that fail at each evaluated time period ## MODEL.COXPH.SURVFIT.PROP.FAIL <- MODEL.COXPH.SURVFIT$n.event/MODEL.COXPH.SURVFIT$n.risk # Length of time over which these failure occurs ## MODEL.COXPH.SURVFIT.TIME <- MODEL.COXPH.SURVFIT$time MODEL.COXPH.SURVFIT.TIME.0 <- c(0,MODEL.COXPH.SURVFIT.TIME[-length(MODEL.COXPH.SURVFIT.TIME)]) # Instantaneous Hazard rate ## MODEL.COXPH.SURVFIT.INSTANTANEOUS.HAZARD <- MODEL.COXPH.SURVFIT.PROP.FAIL/(MODEL.COXPH.SURVFIT.TIME - MODEL.COXPH.SURVFIT.TIME.0) ########################################################################################## ########################################################################################## ########################################################################################## ########################################################################################## If i multiply the "baseline hazard values(MODEL.COXPH.BASELINEHAZ)" with the computed values of "exp(X*beta)", then the resulted values is not matching with the instantaneous hazard values which has been obtained. So is, InstantaneousHazard = h_0(t) exp(X*beta). i.e; is instantaneous hazard is equal to the values which has been computed as "h(t)= baseline hazard values(MODEL.COXPH.BASELINEHAZ)* exp(X*beta)". If not, then please help me in obtaining the appropriate hazard function(H(t)). Please oblige. Regards, Yashwanth M.R -- View this message in context: http://r.789695.n4.nabble.com/How-to-compute-hazard-function-using-coxph-object-tp4635597.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] ______________________________________________ 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.