0

I have my data frame like this

 Product_ID     min_date    max_date
1             2014-09-09    2014-09-09
2             2014-08-18    2014-09-16
3             2012-03-11    2014-11-01
4             2013-01-10    2014-05-02
5             2013-01-23    2014-10-20
6             2013-10-24    2013-10-24
7             2013-03-11    2013-03-11

Where min_date and max_date indicates the time boundary (start date of buying and last date of buying) for each product_ID. I have tried to fit cox proportional hazard using the following code

require(survival)
cox.model <- coxph(Surv(as.numeric(min_date, max_date)) ~ X + frailty(Product_ID), M)   

M is my data of the above form, It ran well.Now I am trying to predict customer churn and all other related survival analysis (KM estimate) and plot the churn & hazard rates. Help me please in this context.

I have managed to construct a data frame for 'transaction' type too, for the association rule analysis. It will be great if you can figure out any type of survival analysis by using the 'transaction' format data set in R programming.

Thanks.

Note:: link for LOESS plot http://192.168.2.165:8787/graphics/plot_zoom?width=881&height=475&scale=1

Hindol Ganguly
  • 363
  • 1
  • 4
  • 16
  • It's not clear what you're asking or where you're having problems. What are you running into issues with when attempting to predict customer churn? What have you tried that doesn't work? – Tchotchke Jun 06 '16 at 12:22
  • the code i mentioned above ran well. my problem is how can i predict customer churn from the above described operation. to validate the fitted cox model, i have used schoenfeld residual under smoothing method 'LOESS' and i have a plot using ggplot. but i can not interpret or predict anything using the plot. – Hindol Ganguly Jun 06 '16 at 12:41
  • Are you having trouble with `predict`? How does your question differ from [this post](http://stackoverflow.com/questions/30993197/predict-probability-from-cox-ph-model)? – Tchotchke Jun 06 '16 at 12:46
  • 1. help me in predicting customer churn 2. using the plot link, please help me in interpreting the plot result. what does it actually suggest about the validation of coxph – Hindol Ganguly Jun 06 '16 at 12:47
  • 1
    The Surv function is not being given the right arguments. When given two time vectors , all subjects are assumed "dead". The results probably don't apply to "churn". – IRTFM Jun 07 '16 at 15:43
  • can you please guide me how can i proceed to predict the churn? i have performed the RFM Analysis based on customer id, date of purchase and amount paid data column. here, i have assigned status 0 for left customers and status 1 for leaving customers. i have used this code yesterday. coxfit1 <- coxph(Surv(as.numeric(Recency), status)~id, data=f) & then survfit(coxfit1,newdata=f) the codes ran well. then i have used base<-basehaz(coxfit1) pred.val<-0.7232*exp(mresid2) where mresid2 is the Martingale residual of type "lp". [code:mresid2<-(f$status-0)- predict(coxfit1, type="lp")] – Hindol Ganguly Jun 08 '16 at 06:31
  • continued.... 0.7232 is the hazard of time 53. now i do not know how to use the basehaz function properly in prediction. i have just consulted internet and i do not have any solid understanding. by the newest operation i have carried out, can i predict the churn? or more specifically, can i say if a customer leaves, how likely he will come in any future time period? thank you. – Hindol Ganguly Jun 08 '16 at 06:34

0 Answers0