Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Loan: Marketing Consideration to Undisciplined Group of Borrowers

Hi. Here, the fundamental building blocks of practical conditional probability. Hopefully, at least, it give insight into the particular circumstance that only you can figure it out. The procedures are not that interesting but your choice of the approach could be. You might be much more creative than you think you are. I made this in my spare time and not sure why I should do it and why you should read it. But you do read it anyway.

So you have a limited allocated budget left for the marketing/advertisement department. After reviewing the lead you accidentally observe a particular group of people consisting of 5.

There's something interesting about this particular group. These borrowers sometimes miss their monthly installment due dates, delaying payment to a future date. However, they tend to catch up on their payments in subsequent months. Just because they don't have such dicipline in term of monthly installment due date doesn't necessarily mean they can't accomplish the overall payment. Althought they are inheritenly "risky" choices.

After a quick research you find that they are not generally bright in term of overall individual economy but due to various reasons they might be trustable in term of independent income. Last year, you record their collective missed monthly payment.

This year they borrow again, it has only been 3 months . You are not sure whether or not to allocate fraction of marketing fund for them in the next round. You're forced to decide it NOW! By observing their activities in 3 months

$\begin{matrix} & 1 & 2 & 3 \\ \text{Person 1} & B & \neg B & B \\ \text{Person 2} & \neg B & \neg B & B \\ \text{Person 3} & B & B & B \\ \text{Person 4} & \neg B & B & \neg B \\ \text{Person 5} & B & \neg B & \neg B \\ \text{Tendency:} & B & \neg B & B \\ \text{Mean (\%):} & 60\% & 40\% & 60\% \end{matrix}$

*$\neg B$ means missing the due date (that man skip the monthly installment due to some unknown financial instabilities)

Your advertisement team decide that they'll invest IF there are at least four accumulated $B$ for 7 months duration (total of 4 B in Tendency) in this year. Meaning, "at least, on average there are 4 times out 7 months they pay on/in time". But how is your marketing team supposed to know after 7 months there could be 4 $B$ if it's only been 3 months? 4 months left and they have to decide it now!?

  • Q: why not waiting after 7 months before deciding?
  • A: I leave the interpretation as your own. But let's say this is the current marketing budget for the next round. If you want to buy something in the future, you allocate the money (saving up) from now, not later. Because in the future you might have another thing to buy and realize that you don't have enough money.

And this is the last year data of monthly installment (7 months for those people)

$\begin{matrix} & \begin{matrix} 1 & 2 & 3 & 4 & 5 & 6 & 7 \end{matrix} \\ \begin{matrix} \text{P1} \\ \text{P2} \\ \text{P3} \\ \text{P4} \\ \text{P5} \end{matrix} & \begin{pmatrix} B & \neg B & B & B & \neg B & B & \neg B \\ \neg B & \neg B & B & \neg B & B & B & \neg B \\ B & B & B & \neg B & \neg B & \neg B & B \\ \neg B & B & \neg B & B & B & \neg B & \neg B \\ B & \neg B & \neg B & \neg B & B & B & B \end{pmatrix} \\ \text{Tendency:} & \begin{matrix} B & \neg B & B & \neg B & B & B & \neg B \end{matrix} \\ \text{Mean (\%):} & \begin{matrix} 60\% & 40\% & 60\% & 40\% & 60\% & 60\% & 40\% \end{matrix} \end{matrix}$

This is not simply about "completing" or "not completing" the montly installment . It isn't straightfowardly 50-50 chance where the prob. weight is $0.5$. Due to various circumtances (economy, lossing jobs, giving birth, etc). The weight is rather random (could be biased toward varying circumtances).

If you consider there are varying circumtances (unknown factors) affecting the weight $r$, defining the random variable $Y_{N}$ to be the number of B observed in $7$ months this year, we need the distribution of $r$ conditioned on the value of $Y_{N}$:

$\underbrace{p(r \mid Y_{N})}$ This is the posterior, the distribution of unknown $r$ after observing the past outcomes.

Linking the past & the future

  • Your prior believe is the probability density $p (r)$, you don't know $r$ but you know it must falls around $[0.0,1.0]$ it follows the beta probability density

  • $P(y_{N} \mid r)$ it's $\textbf{the likelihood}$. You choose the binomial distribution function. It's the likelihood because $r$ varies (based on the observation about the "collective missed due date" ).

  • and $p(r \mid Y_{N})$ is your updated believe about $r$ after observing .

They are linked in this way

$p(r \mid y_{N}) = \frac{P(y_{N} \mid r) p(r)}{P(y_{N})}$

That $P(y_{N})$ doesn't contains $r$, it won't change the distribution shape of $p(r \mid y_{N})$ so it can be ommited. But what is the distribution of $p(r \mid y_{N})$? You use the concept called $\textbf{conjugate prior}$

The conjugate prior says that the pair of likelihood distribution $(P(y_{N} \mid r)$ and the prior distribution $(p(r))$ are said to be conjugate if it has the same distribution with $p(r \mid y_{N})$ (your updated belief about $r$).

In short

$$beta \propto (binomial)(beta)$$

$p(r \mid y_N) \propto P(y_N \mid r) p(r)$

Replacing the terms on the right hand side with a $\textbf{binomial}$ and $\textbf{beta}$ distribution gives:

$p(r|y_N) \propto \left[ \binom{N}{y_N} r^{y_N} (1-r)^{N-y_N} \right] \times \left[ \frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)} r^{\alpha-1} (1-r)^{\beta-1} \right]$

The expected value you would invest in this people is defined as

$\mathbb{E}_{p(r \mid y_{N})}\{P(Y_{7}\geq 4 )\}=\int_{r=0}^{r=1} P(Y_{7}\geq4 \mid r)\underbrace{p(r \mid y_{N})}_{posterior}dr$

$\to$ $Y_{\text{new}}$ is a random variable describing the number of B in a future set of 7 months.

Because the prior and likelihood are conjugate, we know that $p(r|y_N)$ has to be a beta density (same distribution with the prior $(p(r))$. The beta density, with the updated parameters $\delta$ and $\gamma$ ($\alpha$ and $\beta$ in updated, posterior circumtances), has the following general form:

$\mathcal{p}(r)= K r^{\delta-1}(1-r)^{\gamma-1},$

where $K$ is a constant. To mitigate the form above, separate both distribution constants and match the terms involving paramaters $r$.

$\begin{align*} p(r|y_N) &\propto \left[ \binom{N}{y_N} \frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)} \right] \times \left[ r^{y_N} r^{\alpha-1} (1-r)^{N-y_N} (1-r)^{\beta-1} \right] \\ &\propto r^{y_N+\alpha-1} (1-r)^{N-y_N+\beta-1} \\ &\propto r^{\delta-1} (1-r)^{\gamma-1} \end{align*}$

where $\delta = y_N + \alpha$ and $\gamma = N - y_N + \beta$.

Therefore $p(r|y_N) = \frac{\Gamma(\alpha + \beta + N)}{\Gamma(\alpha + y_N)\Gamma(\beta + N - y_N)} r^{\alpha + y_N - 1} (1-r)^{\beta + N - y_N} \\= \frac{\Gamma(\delta + \gamma)}{\Gamma(\delta +\gamma)} r^{\delta - 1} (1-r)^{\gamma-1} $

The computation process

If you know what might be the one exact reason causing those people successfully complete the monthly installment at particular months (say, they all have jobs at those months, although data shows that they sometimes missed the due date) then your inial belief is that $r$ tend to bias toward $B$ (completing the monthly installment) so you choose the parameters like $\alpha= 2$ and $\beta =1$ (there are more topics about the choices of the values, feel free to research more).

However, let's just say you are not sure, the weight is totally random. So you choose $\alpha =1$ & $\beta =1$

To track uncertainty in $r$ each month, we'll use the expected value which follows a $Beta(\delta,\gamma)$ distribution

The posterior expected value is calculated by integrating $r$ over this updated posterior distribution:

$E_{p(r\mid y_N)}\{R\} = \int_{0}^{1} r \cdot p(r \mid y_n) \, dr = \frac{\delta}{\delta + \gamma}$

1). in the prior state you have

$E_{p(r)}\{R\} = \alpha / \alpha + \beta = 1/2$

2). After the first month (in the last year data), it shows $B$ (those group on average complete the monthly installment payment),

$E_{p(r\mid y_N)}\{R\} = \delta /\delta + \gamma = \alpha + y_N / (\alpha + y_N) + (\beta + N-y_N) = (1+1)/1+1 +(1+1-1)= 2/3$

  • $y_N$ is the current number of $B$ obtained so far

3). If you keep updating the paramaters then your updated paramaters and expectancy are in the following tables

$\left[ \begin{array}{ccccccc} N & \text{Outcome} & \delta = \alpha + y_N & \gamma = \beta + N - y_N & \mathbb{E}[R] = \frac{\delta}{\delta+\gamma} & \text{var}\{R\} = \frac{\delta\gamma}{(\delta+\gamma)^2(\delta+\gamma+1)} & \text{Decimal Values} \\ 0 & - & 1 & 1 & \frac{1}{2} & \frac{1}{12} & E \approx 0.5000, \text{var} \approx 0.0833 \\\\ 1 & B & 2 & 1 & \frac{2}{3} & \frac{1}{18} & E \approx 0.6667, \text{var} \approx 0.0556 \\\\ 2 & \neg B & 2 & 2 & \frac{1}{2} & \frac{1}{20} & E = 0.5000, \text{var} = 0.0500 \\\\ 3 & B & 3 & 2 & \frac{3}{5} & \frac{1}{25} & E = 0.6000, \text{var} = 0.0400 \\\\ 4 & \neg B & 3 & 3 & \frac{1}{2} & \frac{1}{28} & E = 0.5000, \text{var} \approx 0.0357 \\\\ 5 & B & 4 & 3 & \frac{4}{7} & \frac{3}{98} & E \approx 0.5714, \text{var} \approx 0.0306 \\\\ 6 & B & 5 & 3 & \frac{5}{8} & \frac{5}{192} & E = 0.6250, \text{var} \approx 0.0260 \\\\ 7 & \neg B & 5 & 4 & \frac{5}{9} & \frac{2}{81} & E \approx \underline{0.5556}, \text{var} \approx 0.0247 \end{array} \right]$

def calc_beta_stats(alpha, beta, sequence):
    results = []
    # N=0
    d = alpha
    g = beta
    e = d / (d + g)
    v = (d * g) / (((d + g) ** 2) * (d + g + 1))
    results.append((0, '-', d, g, f"{d}/{d+g}", f"{d*g}/{((d+g)**2)*(d+g+1)}", f"E={e:.4f}, var={v:.4f}"))
    y_N = 0
    for N, outcome in enumerate(sequence, 1):
        if outcome == 'B':
            y_N += 1
        d = alpha + y_N
        g = beta + N - y_N
        e = d / (d + g)
        v = (d * g) / (((d + g) ** 2) * (d + g + 1))
        # Simplify fraction representations roughly or just format string
        results.append((N, outcome, d, g, f"{d}/{d+g}", f"{d*g}/{(d+g)**2 * (d+g+1)}", f"E={e:.4f}, var={v:.4f}"))
    return results
seq = ['B', '¬B', 'B', '¬B', 'B', 'B', '¬B']
res = calc_beta_stats(1, 1, seq)
for row in res:
    print(row)

at the 7th month $E_{p(r\mid y_N)}{R} \approx 0.5556$

Grafik Analisis Probabilitas

The margin in the $r$ range indicates the uncertainty in the value of $r$ is still arguably high, but this understandable, you have only observed data for 7 months

by the definition of expectations, this is given by:

$\quad \mathbf{E}_{p(r|y_N)} \{ P(Y_{\text{new}} = y_{\text{new}}|r) \} = \int_{r=0}^{r=1} \underbrace{P(Y_{\text{new}} = y_{\text{new}}|r)}_{\text{likelihood (binomial)}} \underbrace{p(r|y_N)}_{\text{ posterior(beta)}} \, dr$

As already mentioned due to the \textit{conjugate prior} rule the \textbf{posterior} is the beta density (with $\delta$ & $\gamma$ ), therefore

$\delta = \alpha + y_{new} \\ \gamma = \beta + N_{new} - y_{new}$

$\\ = \int_{r=0}^{r=1} \left[ \binom{N_{\text{new}}}{y_{\text{new}}} r^{y_{\text{new}}} (1 - r)^{N_{\text{new}} - y_{\text{new}}} \right] \left[ \frac{\Gamma(\delta + \gamma)}{\Gamma(\delta)\Gamma(\gamma)} r^{\delta - 1} (1 - r)^{\gamma - 1} \right] \, dr \\\\ \text{ get out the constants and arrange the exponents} \\\\ = \binom{N_{\text{new}}}{y_{\text{new}}} \frac{\Gamma(\delta + \gamma)}{\Gamma(\delta)\Gamma(\gamma)} \int_{r=0}^{r=1} r^{y_{\text{new}} + \delta - 1} (1 - r)^{N_{\text{new}} - y_{\text{new}} + \gamma - 1} \, dr$

$\text{In general, for a beta density with parameters } \delta \text{ and } \gamma \text{ the following \textit{must} be} \text{true:}$

$\int_{r=0}^{r=1} \frac{\Gamma((y_{new}+ \delta) +(N_{new} -y_{new}+\gamma))}{\Gamma((y_{new}+ \delta) )\Gamma((N_{new} -y_{new}+\gamma)))} r^{\delta-1}(1 - r)^{\gamma - 1} \, dr = 1,$

\text{and therefore:}

$\int_{r=0}^{r=1} r^{\delta - 1} (1 - r)^{\gamma - 1} \, dr = \underbrace{ \frac{ \Gamma((y_{new}+ \delta) )\Gamma((N_{new} -y_{new}+\gamma)))}{ \Gamma((y_{new}+ \delta) +(N_{new} -y_{new}+\gamma)) }}_{\text{ switched denominator}}$

\text{The expectation becomes:}

$\mathbf{E}_{p(r|y_N)} \{ P(Y_{\text{new}} = y_{\text{new}}|r) \} = \binom{N_{\text{new}}}{y_{\text{new}}} \frac{\Gamma(\delta + \gamma)}{\Gamma(\delta)\Gamma(\gamma)} \frac{\Gamma(\delta + y_{\text{new}})\Gamma(\gamma + N_{\text{new}} - y_{\text{new}})}{\Gamma(\delta + \gamma + N_{\text{new}})}$

$\text{which you can easily compute for a particular posterior (i.e. values of } \gamma \text{ and } \delta\text{) and} \text{values of } N_{\text{new}} \text{ and } y_{\text{new}}.$

You already saw 2 $B$ (the commulative completion of the montly installment). To reach a total threshold of $\ge 4$; $B$ across the 7-month block this year, you aggregate the probabilities where $y_{\text{new}} \geq 2$:

$\mathbf{E}_{p(r|y_{N})}\{P(Y_{\text{new}}\ge 2|r)\}=P(Y_{\text{new}}=2)+P(Y_{\text{new}}=3)+P(Y_{\text{new}}=4) $

For $y_{\text{new}} = 0$:

$\begin{aligned} \mathbf{E}_{p(r|y_{N})}\{P(Y_{\text{new}}=0|r)\} &= \binom{4}{0}\cdot 280\cdot \frac{\Gamma (5)\Gamma (8)}{\Gamma (13)} \\ &= 1\cdot 280\cdot \frac{4!\times 7!}{12!} \\ &= 280\cdot \frac{24\times 5,040}{479,001,600} \\ &= \frac{33,868,800}{479,001,600} = \frac{7}{99}\approx 0.0707 \end{aligned}$

For $y_{\text{new}} = 1$: $\begin{aligned} \mathbf{E}_{p(r|y_{N})}\{P(Y_{\text{new}}=1|r)\} &= \binom{4}{1}\cdot 280\cdot \frac{\Gamma (6)\Gamma (7)}{\Gamma (13)} \\ &= 4\cdot 280\cdot \frac{5!\times 6!}{12!} \\ &= 1,120\cdot \frac{120\times 720}{479,001,600} \\ &= \frac{96,768,000}{479,001,600} = \frac{20}{99}\approx 0.2020 \end{aligned}$

For $y_{\text{new}} = 2$: $\begin{aligned} \mathbf{E}_{p(r|y_{N})}\{P(Y_{\text{new}}=2|r)\} &= \binom{4}{2}\cdot 280\cdot \frac{\Gamma (7)\Gamma (6)}{\Gamma (13)} \\ &= 6\cdot 280\cdot \frac{6!\times 5!}{12!} \\ &= 1,680\cdot \frac{720\times 120}{479,001,600} \\ &= \frac{145,152,000}{479,001,600} = \frac{30}{99}=\frac{10}{33}\approx 0.3030 \end{aligned}$

For $y_{\text{new}} = 3$: $\begin{aligned} \mathbf{E}_{p(r|y_{N})}\{P(Y_{\text{new}}=3|r)\} &= \binom{4}{3}\cdot 280\cdot \frac{\Gamma (8)\Gamma (5)}{\Gamma (13)} \\ &= 4\cdot 280\cdot \frac{7!\times 4!}{12!} \\ &= 1,120\cdot \frac{5,040\times 24}{479,001,600} \\ &= \frac{135,475,200}{479,001,600} = \frac{28}{99}\approx 0.2828 \end{aligned}$

For $y_{\text{new}} = 4$: $\begin{aligned} \mathbf{E}_{p(r|y_{N})}\{P(Y_{\text{new}}=4|r)\} &= \binom{4}{4}\cdot 280\cdot \frac{\Gamma (9)\Gamma (4)}{\Gamma (13)} \\ &= 1\cdot 280\cdot \frac{8!\times 3!}{12!} \\ &= 280\cdot \frac{40,320\times 6}{479,001,600} \\ &= \frac{67,737,600}{479,001,600} \\ &= \frac{14}{99}\approx 0.1414 \end{aligned}$

$\mathbf{E}_{p(r|y_{N})}\{P(Y_{\text{new}}\ge 2|r)\}=\sum _{y_{\text{new}}=2}^{4} \mathbf{E}_{p(r|y_{N})}\{P(Y_{\text{new}}=y_{\text{new}}|r)\} \\\mathbf{E}_{p(r|y_{N})}\{P(Y_{\text{new}}\ge 2|r)\} \\=P(Y_{\text{new}}=2)+P(Y_{\text{new}}=3)+P(Y_{\text{new}}=4) \\=\frac{30}{99}+\frac{28}{99}+\frac{14}{99}=\frac{72}{99}=\frac{8}{11} \approx 0.7273$

that's 72.7% expectancy, therefore your marketing team should allocate the fraction of budget for this particular group too.

About

The analytics

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors