Calculating Customer Lifetime Values using a Shifted-Beta-Geometric model | by Farshad Lavassani Miraftab | Towards Data Science

Customer lifetime values (CLV) are a critical metric considered to be a company’s north star metric and all in-compassing KPI, used to inform:
marketing campaigns — how much should we spend to acquire customers?
customer segmentation — who are our most valuable customers and what are their demographic and behavioral traits?
overall health of the business — how is our CLV changing over time?
total company value — how can we estimate the value of our existing and future customers?
But what is CLV?
The present value of all future cash flows of a current customer
At a high-level, in order to estimate your CLV you’ll need to understand two simple customer attributes; a customers lifetime and the revenue they generate on a recurring basis. The more a customer pays and the longer they stay as a customer, the greater their CLV.
This post will focus on the more challenging component — measuring a customers lifetime, which requires you to understand your businesses current retention rates.
This post aims to provide an end-to-end robust methodology to estimate customer lifetime values.
The formula below is traditionally used to calculate CLV for most recurring revenue businesses.
However, there are 3 major issues with this methodology:
This formula computes a single number expressing the expected customer lifetime value (or the average). It disregards any uncertainty in our estimates. For instance, in SaaS businesses, the revenue contributions by the customers can vary greatly, especially if you have different service plans (basic vs premium).
Arguably the most significant issue is using an aggregate retention rate among your customers. The essence of the proposed methodology is to account for the different retention rates for different customers. More to come in later.
2 inherent business dimensions should influence your CLV methodology.
Contractual vs Non-Contractual: In contractual businesses (e.g., Netflix, SaaS, Credit Cards), churn is explicitly observed. For instance, most SaaS customers are subscription-based and thus a customer will have to cancel in order to churn. Non-contractual businesses (e.g., online retail, grocery stores) don’t know if the customer's last purchase was truly their last or if they’ll eventually return to make another purchase.
Continuous vs Discrete: Transaction frequency is the second dimension. In discrete payment settings such as Netflix and fitness clubs, customers pay on a fixed cycle (i.e., monthly, yearly). In continuous payment settings such as Amazon, credit cards, payments are less predictable. For instance, although credit card companies know when you’ve churn (contractual) they don’t know how frequently you’ll generate transactions in a given month.
The issues outlined above all influence how we evaluate a customers lifetime. The remainder of this post will demonstrate a more robust method to evaluate your customer's retention rate specifically for Contractual — Discrete business.
Assume a cohorted customers table tracking year-over-year retention. Green values reflect current active customers.
Retention rates reflect the percent of customers that survive between subsequent periods. Churn rates are complementary to retention rates (i.e, 1 minus retention). Survival rates reflect the percent of customer that have survived since the beginning period. Survival at time t can be defined as:
Let’s compute the retention and churn rates for our oldest cohort, Cohort 0:
Annual Retention and Churn Rates for Cohort 0r1 = 84% (840 / 1000) --> c1 = 1 - .84 = 16%r2 = 73% (618 / 840)  --> c2 = 1 - .73 = 27%r3 = 92% (570 / 618)  --> c3 = 1 - .92 = 8%r4 = 91% (519 / 570)  --> c4 = 1 - .91 = 9%Average Retention = 85%
The resulting survival rate for the same cohort:
Annual Survival Rates for Cohort 0S1 = r1 = 84%S2 = r1 * r2 = 84% * 73% = 61%S3 = r1 * r2 * r3 = 84% * 73% * 92% = 57%S4 = r1 * r2 * r3 * r4 = 84% * 73% * 92% * 91% = 52%
The challenge becomes forecasting the retention and survival rates, beyond our oldest cohort; we don’t know what percent of the 519 current customers from cohort 0 will be alive next year (year 5).
How we can take our 4yr data and forecast out to 5+ yrs?
One approach is to take the average retention rate across all years and forecast.
The chart above reflects our survival rates for each cohort. The average retention rate across these cohorts is ~84.4% which can be used to forecast survival rates for all times t using the survival formula.
Only ~20% of customers in a cohort will remain by the 9th year (.8449), as seen by the chart using an average retention. The next section proposes an alternative approach to forecasting retention.
The sGB model is great method to forecast retention for contractual businesses with discrete payment cycles. Although this post will not get into the mathematical details, it will help develop some fundamental intuition around the approach.
The formula above is the retention rate at time t for the sGB. Parameters α, β need to be estimated in a fashion that best fit our cohorted data. Let’s build some intuition around the formula:
Assume α = 2 and β = 10:r1 = (10+1-1) / (2+10+1-1) = 83.3%r2 = (10+2-1) / (2+10+2-1) = 84.6%                ...r5 = (10+5-1) / (2+10+5-1) = 87.5%
Notice how retention not only is no longer constant but increasing over time. This subtly provides flexibility to more accurately model retention behavior and is a key enhancement in using a sGB model.
Because churn and retention are complementary, knowing one enables us to measure the other. The beta distribution is a flexible distribution that is used to model churn rates using the parameters, α and β mentioned earlier.
The chart below categorizes the types of survival curves based on sampled churn probabilities using the beta distribution. Each quadrant has a pair of charts — the left chart is the churn rates for a a given α and β and the right chart is its corresponding survival curve.
Below is the interpretation, demonstrating how different churn rates impact the survival rates.
The question that remains is “how can I identify what the α and β parameters are for my business?”. The Maximum Likelihood Estimate (MLE) of the model parameters allow us to estimate the parameters that best fit our businesses observed cohorted data.
TL;DR Find values for α and β that maximize the output of the function above
There are many methods to optimize log-likelihood function above such as scipy, pymc3, or even excels solver add-ons. However, if you want to optimize probabilistically to account for uncertainties in the parameter estimates, pymc3 is a great choice. With pymc3, you can sample the posterior distribution to see the likely values to our parameters, as shown next.
We can sample the posterior distribution and visualize the uncertainty associated with our solved parameters:
We can see that the average α ≈ 1.1 and average β ≈ 5.3 placing our parameters in the top right quadrant on average. However, given are relatively small cohort sizes, there is uncertainty in our estimates, reflecting a strong possibility that α < 1 which would result our churn distribution falling into the bottom right quadrant.
Before measuring lifetime values, the next section will explain the value of growing retention rates.
Let’s take the two customers above as an example. Knowing only the number of times the customer as renewed their subscription with a business, which customer is more likely to renew once more (i.e., survive into the next period)? Customer B has demonstrated themself to be a loyal customer, one that clearly loves your product, hence the 9 renewals. You would anticipate that customer B is more likely to renew once more. We can measure this concept by measuring retention rates at t=2 and t=10 yrs using our estimated parameters.
Notice how retention improves at t=10 rewarding out intuition. There is a 92.7% change customer B renews into year 10 but an 84.5% chance customer A renews into year =3.
Using an average retention ignores growing loyalty in customers over time
We can also plot our churn probabilities using beta distribution from our posterior parameter samples.
Each line above reflects a churn distribution for a given α and β . The magenta-coloured lines reflect samples where both α and β were greater than 1 (generally higher churn rate on average). The black line reflects the churn rate distribution assuming our average parameters (α ≈ 1.1 and β ≈ 5.3). On the contrary, the green lines occur when α <1 but β >1.
Being able to compute retention rate at any time t means we compute our survival rate at any time t using our survival formula from earlier. The chart above reflects our forecasted survival curve using the sGB versus the constant retention rate.
Assuming constant retention rate underestimates our customers lifetimes, which in turn will underestimate CLV.
Not only can we now compute the expected lifetimes of future customers but also existing customers; customers that are currently active. The CLV of an existing customer can be expressed as their Residual Lifetime Value (RLV) or remaining lifetime value. Discounting their future value to present-value results in what's referred to as Discounted Expected Residual Lifetime (DERL).
The 2F1function refers to the hypergeometric function which can be imported in python from the scipy library:
from scipy.special import hyp2f1
Much like the increasing retention rates demonstrated earlier, the intuition behind the RLV is that an existing customer having renewed their subscription n times is likely to have a longer lifetime and thus a higher residual value assuming all else constant. Thus, we expect DERL to increase as the number of renewals increases.
Assuming the cash flow per customer to be $1,000 annually, the DERL after each renewal for the first 20 years is seen in the chart below:
The box-plots reflects the uncertainty in our estimate. For instance, for an active customer that has made 2 renewals, we estimate the DERL to be anywhere between $5000 to $5700 with a median of around $5300. Had we a solved for a single α and β we would have a single line. That said, notice the growing trend in residual value over time — in essence, we are quantifying customer loyalty. A newly acquired customer (number of renewals = 0) has a median DERL of around $4,500 verse an active customer that’s made 19 renewals has a median DERL of around $8000 (78% higher).
Referring back to our cohort table, we can see our oldest cohort (Cohort 0) has made 4 renewals resulting in a median DERL of ~$5,900 per customer. Additionally, our newest cohort (Cohort 3) has only made 1 renewal with us and thus have as DERL of $4,900.
Because the DERL value shown above is per customer, the entire cohort Residual Values are obtained by multiplying the DERL by the current number of active customers for that cohort (green values). Summing across all cohorts reflects the total residual value of your existing customers.
Note that we are summing median values; in reality it’s advised to either sum the averages or continue to project the uncertainties to the end at which point you can compute any statistic you like (average, median, percentiles).
The total (median) remaining value for all our active customers is ~$14.2M
Furthermore, assume your business team forecasts a breakthrough year with an additional 1,000 new customers next year. New customers have made 0 renewals and thus have a DERL of ~$4500 per customer. As a result, we estimate those future customers will collectively have a lifetime value of $4.5M (1000 * $4500).
This post intended to demonstrate 3 considerations when evaluating CLV:
Account for uncertainty; if your customer dataset is only a handful of customers, you should less certain when modeling lifetime values.The sGB model is an excellent method to evaluate contractual — discrete businesses; modeling retention and lifetime more intuitivelyResidual Lifetime Values credits loyal customers (older) than new ones assuming all things equal.
Account for uncertainty; if your customer dataset is only a handful of customers, you should less certain when modeling lifetime values.
The sGB model is an excellent method to evaluate contractual — discrete businesses; modeling retention and lifetime more intuitively
Residual Lifetime Values credits loyal customers (older) than new ones assuming all things equal.
These considerations enable you to more accurately compute the total value of your current customers probabilistically and ultimately provide a much more robust and dynamic metric to:
evaluate A/B testing experiments
inform marketing acquisition efforts
raise the next series of funding for your startup!
[1] What’s Wrong With This CLV Formula?
[2] How to Project Customer Retention
[3] Probability Models for Customer-Base Analysis