I have created a cox proportional hazards regression model for predicting churning out in R(using coxph
function from the survival
package).
I am able to see the churning out percentage with number of days of all my customers by plotting the survfit
model of the above coxph
model.
fit_cox <- coxph(formula = form, data = train)
fit_cox_model <- survfit(fit_cox)
plot(fit_cox_model,ylim=c(.4,1), xlab = 'Days since became member', ylab = 'Percent Surviving')
Now I had to predict the probability of each customer churning out after 30 days, 100 days and 1000 days. So I used the function predictSurvProb
from the pec
package.
prob_df <- data.frame(predictSurvProb(fit_cox,newdata=test_set,times=c(1,30,100, 1000)))
With that I am getting the probabilities, but I am not sure how do I validate this model. I just tried to manually compare the churned_out
binary variable with these probabilities which obviously is wrong (But there are so any customers who have already churned out in 60 days but still there probability of surviving in 100 days is high like 0.9).
I even tried validate
from rms
package, and cindex
from pec
package for validation but they both are giving the following errors-
> validate(fit_cox_model)
Error in UseMethod("validate") :
no applicable method for 'validate' applied to an object of class "c('survfit.cox', 'survfit')"
> cindex(list("cox1"=fit_cox), formula = form, data = test_set)
Error in histformula[[2]][[1]] :
object of type 'symbol' is not subsettable
So I want to know -
1) Whether I am following the right procedure for predicting probability of churning out?
2) How do I validate my model ?