-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
89 lines (63 loc) · 2.95 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
title: "README"
date: ""
output:
html_document:
keep_md: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
[![Language](https://img.shields.io/badge/language-R-blue)](https://img.shields.io/badge/language-R-blue)
[![GitHub issues](https://img.shields.io/github/issues/KobaKhit/eCLV)](https://github.com/KobaKhit/eCLV/issues)
[![GitHub forks](https://img.shields.io/github/forks/KobaKhit/eCLV)](https://github.com/KobaKhit/eCLV/network)
[![GitHub stars](https://img.shields.io/github/stars/KobaKhit/eCLV)](https://github.com/KobaKhit/eCLV/stargazers)
[![GitHub license](https://img.shields.io/github/license/KobaKhit/eCLV)](https://github.com/KobaKhit/eCLV)
Collection of functions that compute Expected Customer Lifetime Value in a subscription (contractual) setting based on research by Fader and Hardie. More on [Rpubs](https://rpubs.com/Koba/projecting-clv).
![](README_files/figure-html/unnamed-chunk-1-1.png)<!-- -->
## Usage
We will use the example data from paper 1 in the references section.
```{r, warning=F}
# Load the functions
source("lib-BG.R")
# Example from paper
# Data
activeCust = c(869,743,653,593,551,517,491)
lostCust = c(131,126,90,60,42,34,26)
# Estimate the maximum likelihood function to get the alpha, beta values
# Alternative function to estimate MLL
# estimateMLL2(active.cust = activeCust,
# lost.cust = lostCust)$par
alphabeta = estimateMLL(active.cust = activeCust,
lost.cust = lostCust)$par
alphabeta
# Survival probabilities for 10 periods
periods = 1:10
sProb = survivalBG(alphabeta[1],alphabeta[2], periods)
# Churn probabilities for 10 periods
cProb = churnBG(alphabeta[1],alphabeta[2],periods)
# Get the retention rates for 10 periods
rProb = retentionRates(alphabeta[1],alphabeta[2],periods)
# create plot
dat = data.frame(sProb,cProb,rProb)
matplot(dat, type = c("b"), ylab = 'probability', xlab='period',
pch=1:3,col=c('darkgray','red','blue'), lty=1:3,
main='Shifted Beta Geometric Model Probabilities, t=10')
legend(x=1,y=0.5, legend=c("Survival Prob", "Churn Prob","Retention Prob"),
col=c('darkgray','red','blue'), lty=1:3, pch=1:3)
sProb
cProb
rProb
# Discounted Expected Lifetime
DEL(alphabeta[1],alphabeta[2],discount = 0.1)
# Discounted Expected Residual Lifetime
DERL(alphabeta[1],alphabeta[2],discount = 0.1, renewals = 4)
# Expected Lifetime Value per customer assuming expected net cash flow is 100$ per period
DEL(alphabeta[1],alphabeta[2],discount = 0.1)*100
# Expected Residual Lifetime Value per customer who renewed 4 times
# assuming expected net cash flow is 100$ per period
DERL(alphabeta[1],alphabeta[2],renewals = 4, discount = 0.1)*100
```
## References
1. [How to Project Customer Retention](https://faculty.wharton.upenn.edu/wp-content/uploads/2012/04/Fader_hardie_jim_07.pdf) by Peter Fader and Bruce Hardie (2007)
2. [Fitting the sBG Model to Multi-Cohort Data](http://brucehardie.com/notes/017/) by Peter Fader and Bruce Hardie (2007)