Zainab Jamal
2009-Feb-23 23:23 UTC
[R] predicting cumulative hazard for coxph using predict
Hi I am estimating the following coxph function with stratification and frailty?where each person had multiple events. m<-coxph(Surv(dtime1,status1)~gender+cage+uplf+strata(enum)+frailty(id),xmodel) ?> head(xmodel)id enum dtime status gender cage uplf 1 1008666 1 2259.1412037 1 MA 0.000 0 2 1008666 2 36.7495023 1 MA 2259.141 0 3 1008666 3 0.3026852 1 MA 2295.891 0 4 1008666 4 46.7493287 1 MA 2296.193 0 5 1008666 5 61.9772917 1 MA 2342.943 0 6 1008666 5 100.9964815 1 MA 2404.920 0 If I estimate predict(m,newdata,type="lp") does the output include xbeta or does it include xbeta+frailty term? ? I want to predict the cumulative hazard for each person for their next event at a given time in future.What is the best way to compute it? Currently I am doing it by pulling the different elements and putting them together using my own code. For example, I get the cumulative baseline hazard from the basehaz function bh<-basehaz(m) bh$hazard for the strata in which the predicted event is and the time that matches to the prediction time. xbeta from predict function xbeta<-predict(m,newdata,type="lp") fval<-m$frail Regards Zainab
Terry Therneau
2009-Feb-24 16:23 UTC
[R] predicting cumulative hazard for coxph using predict
> I am estimating the following coxph function with stratification and > frailty, where each person had multiple events.> m <- coxph(Surv(dtime1,status1) ~ gender +cage +uplf+ strata(enum)+ > frailty(id), xmodel)>I want to predict the cumulative hazard for each person for their next event at > a given time in future.What is the best way to compute it?There are two issues. The first is that what you are asking for -- it is not at all clear to me exactly how this should be computed, and as a consequence the coxph routines/documentation are not clear. When there is a random effect in the model, should the baseline hazard be computed before or after integrating out the random effect? How should one define the cumulative hazard for a subject? These are hard questions, or at least I've found them so. What is currently done: The basline hazard is computed treating each of the fitted random effects (one per id) as it if were a known fixed value. The predict function treats the random effects as just another coefficient, which is clearly the wrong thing to do wrt a new subject who was not in the original data set. If you think of the frailty term as a shrinkage estimator, with no particular connection to random effects, then what is currently done makes reasonable sense. The "random effects" are just more coefficients in the model. Terry Therneau