I am attempting to come up with a way of calculating month-over-month customer retention rate with a large data set of 390k rows. Basically, I want to know the percentage of customers present in a month that were also present in the previous month.
So if last month, customers a, b, and c purchased a product. And this month, customers b, c, and d made a purchase. Two of the three customers from last month made a purchase this month. Notice that d did not purchase last month so it is excluded from consideration this month, but next month it will be considered.
I have a simple but representative data frame below.
year_mon = c("2018 Nov", "2018 Nov", "2018 Nov", "2018 Nov", "2018 Nov", "2018 Dec", "2018 Dec", "2018 Dec", "2019 Jan", "2019 Jan", "2019 Feb", "2019 Feb", "2019 Feb")
customer_id = c(1, 2, 3, 4, 5, 2, 3, 4, 3, 4, 1, 2, 3)
data.frame(customer_id, year_mon)
How could I calculate CRR no matter how many months I would have? That is to say, I don't want this hard coded. If I have 30 consecutive months of data or 3 months of consecutive data, I would like a solution that calculates CRR.
From https://www.bitrix24.com/glossary/what-is-customer-retention-rate-definition.php:
Customer Retention Rate = ((EC-NC)/SC)*100, where:
- EC - number of customers at the end of a period
- NC - number of new customers during that period
- SC - number of customers at the start of that period
Let's say you released a mobile game. On September 1st you had 1000 players. You got 500 new players by September 30, however 200 players stopped playing the game. So, at the end of a period (in our case one month) you had 1300 playing customers. Let's calculate the retention rate:
((1300-500)/1000)*100=80
So, you manage to retain 80% of your customers. Each industry has their own "good" and "bad" retention rates. Needless to say, every company tries to retain maximum percentage of customers.
EDIT @r2evans here the solution you offered seems to have "reset" for January of both years oddly enough. I verified that there are customers present in December also in January, so the CRR should not have been zero. I'm wondering if there is any explanation that can account for this.
