I'm working on creating a survival model to forecast customer retention using the Cox Proportional Hazard model in R. I'm using the tenure of existing customers, in addition to other metrics, such as location, to forecast what their survival likelihood is looking x days into the future.

I use tenure as a parameter because a customer who has been around for 250 days is much more likely to retain than one who was sold 30 days ago.

I've run into an issue in building the model and handling the tenure parameter. For my first attempt, I pulled the historical data of customers and assigned tenure as a random integer between 0 and how long they have been a customer and built the model using that. While forecasting retention using this method, current customers with low tenure were essentially penalized as the customers in the data used to build the model with a low tenure were likely to have retained poorly (random number between 0-30 for a poorly retaining customer is much more likely to be low vs a random number between 0-735 for a customer who retains well). Retention for these early customers was lower than I would have expected.

For my second attempt to build the model, I applied created a data point for each day a customer was in our network. (E.g. a customer who retained 30 days would have 30 lines (1-30) and one who retained for 735 days would have 735.) This worked well for the tenure parameter but I think it too heavily weighted well retaining customers for parameters that weren't time dependent (location, for instance). Using this methodology, retention was higher than expected for these customers.

I'm wondering if there is a way to handle both of these parameters so as to not weight non time dependent parameters too heavily but still accurately take tenure into account.



1 Answer 1


What you have available are data on past or current customers and their characteristics that you want to include in the model. For past customers you have the duration over which each was held, with current customers right-censored at their current tenure. Some customer characteristics change over time, which you can include as time-varying predictor values in standard Cox models. This vignette for the survival package in R shows how to use such predictors.

There is no reason why the accumulated tenure itself could not be used as a time-varying predictor, as what matters to a Cox model is the set of predictor values at a certain time. You need, however, to be careful how you proceed.

That might be what you mean by your second approach, if each line includes the tenure up to that time as a time-dependent predictor (along with all other predictor values in place at that time). The trick will be not to assume a simple linear relationship between tenure and log-hazard, which is what would be modeled by default. You should model that predictor flexibly, for example as a cubic spline, to capture any non-linearity in the relationship.

Be warned, however, that time-dependent covariates can run a risk of survivorship bias. There's a risk of using the fact of a long tenure as a predictor of a long tenure. For example, if a customer with a particular set of characteristics was held for less than 200 days, that customer couldn't have been held for 250 days. You can quickly get into circular reasoning, so make sure that your modeling doesn't fall into that trap.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.