Problem
Analysts who model customer lifetime value need a distribution for time to churn. Common choices are the exponential, gamma, Weibull and log-normal, and the best one depends on the data. Trying each means writing and checking several models. The author builds lifetime value models and wants one likelihood that covers them, so he can skip that search on every new dataset.
Example from the article: the author fits survival curves to the veteran dataset from the R package {survival}, one curve per treatment group, because its survival function is roughly exponential.
Solution in brief
Fit a generalized gamma distribution. The exponential, gamma and Weibull distributions are special cases, and the log-normal is a limiting case, so one model can match whichever shape the data follow. Stan has no built-in version, so the post gives the log density, log CDF, log complementary CDF and random number generator as Stan functions.
Questions this case answers
- How to fit one flexible parametric time-to-event model to censored data when it is unclear which standard distribution fits best
- How to model time to churn or customer lifetime without testing several survival distributions one by one?
- How to use the generalized gamma distribution for censored lifetime data in Stan?
- How to check that a fitted parametric survival model matches the Kaplan-Meier curve?
Tools and methods
- Generalized gamma distribution — flexible parametric model for event time, with parameters , and
- Stan — fits the model by Markov chain Monte Carlo (MCMC); the density functions go in the functions block
- Kaplan-Meier estimate — non-parametric curve used as the reference for the fit
- Posterior predictive check — compares the empirical CDF (ECDF) of simulated event times with the Kaplan-Meier curve
Google or a one-time email code. No password.