I'm trying to use a Cox proportional hazard model to predict the time until an employee terminates from an organization. There are a bunch of covariates (~20), some of them time-dependent. So I've structured my data appropriately, created a survival object, and fed it to the coxph function successfully. Abbreviated code sample:
surv1 = Surv(Interval.Start, Interval.End, Is.Term.Record)
fit1 = coxph(surv1 ~ Age + Tenure + Gender + Stock + Perf, data=mydata)
I have a limited understanding of semi-parametric models and I'm a beginner in R, so I understand the coef and stats output but I don't know how to use fit1
to make predictions given data on a current employee despite reading some of the other posts on this topic. Should I be using something like
predict(fit1,newdata=covs,type="expected")
...but in that case, what should covs
look like? And what will the output be--the expected time-to-termination or something else?
Thanks.
?predict.coxph
and you may also need?survfit.coxph
$\endgroup$?survfit.coxph
. Unless you haveattach
-ed the dataset, your creation of theSurv()
object will not have succeeded. Therneau specifically warns against creating Surv-objects outside of the 'coxph' function because of later difficulties with the environments not being correctly accessible. $\endgroup$Surv()
insidecoxph()
in my original code. I changed it in my post for aesthetics, but you're right, I should've been more careful. My mistake. Also, after reading?predict.coxph
several times, I still don't understand exactly what thenewdata
argument should look like when making a new prediction. I'm also not sure what you mean by "a set of covariates that match the original set as well as covering the time intervals of interest for the prediction". Can you provide an example table? Thanks for your responses...I've been struggling with this for days! $\endgroup$