<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/modeling-lgd-with-proportional-odds-model/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://statcompute.wordpress.com/2018/01/28/modeling-lgd-with-proportional-odds-model/"> S+/R – Yet Another Blog in Statistical Computing</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>The LGD model is an important component in the expected loss calculation. In <a rel="nofollow" href="https://statcompute.wordpress.com/2015/11/01/quasi-binomial-model-in-sas" target="_blank">https://statcompute.wordpress.com/2015/11/01/quasi-binomial-model-in-sas</a>, I discussed how to model LGD with the quasi-binomial regression that is simple and makes no distributional assumption.</p>
<p>In the real-world LGD data, we usually would observe 3 ordered categories of values, including 0, 1, and in-betweens. In cases with a nontrivial number of 0 and 1 values, the ordered logit model, which is also known as Proportional Odds model, can be applicable. In the demonstration below, I will show how we can potentially use the proportional odds model in the LGD model development. </p>
<p>First of all, we need to categorize all numeric LGD values into three ordinal categories. As shown below, there are more than 30% of 0 and 1 values. </p>
<pre>
df &lt;- read.csv(&quot;lgd.csv&quot;)
df$lgd &lt;- round(1 - df$Recovery_rate, 4)
df$lgd_cat &lt;- cut(df$lgd, breaks = c(-Inf, 0, 0.9999, Inf), labels = c(&quot;L&quot;, &quot;M&quot;, &quot;H&quot;), ordered_result = T)
summary(df$lgd_cat)

#   L    M    H 
# 730 1672  143 
</pre>
<p>The estimation of a proportional odds model is straightforward with clm() in the ordinal package or polr() in the MASS package. As demonstrated below, in addition to the coefficient for LTV, there are 2 intercepts to differentiate 3 categories. </p>
<pre>
m1 &lt;- ordinal::clm(lgd_cat ~ LTV, data = df)
summary(m1)

#Coefficients:
#    Estimate Std. Error z value Pr(>|z|)    
#LTV   2.0777     0.1267    16.4   &lt;2e-16 ***
#---
#Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#
#Threshold coefficients:
#    Estimate Std. Error z value
#L|M  0.38134    0.08676   4.396
#M|H  4.50145    0.14427  31.201
</pre>
<p>It is important to point out that, in a proportional odds model, it is the cumulative probability that is derived from the linear combination of model variables. For instance, the cumulative probability of LGD belong to L or M is formulated as<br>
<strong><br>
Prob(LGD &lt;=M) = Exp(4.50 – 2.08 * LTV) / (1 + Exp(4.50 – 2.08 * LTV))<br>
</strong><br>
Likewise, we would have<br>
<strong><br>
Prob(LGD &lt;=L) = Exp(0.38 – 2.08 * LTV) / (1 + Exp(0.38 – 2.08 * LTV))<br>
</strong><br>
With above cumulative probabilities, then we can calculate the probability of each category as below.<br>
<strong><br>
Prob(LGD = L) = Prob(LGD &lt;=L)<br>
Prob(LGD = M) = Prob(LGD &lt;=M) – Prob(LGD &lt;=L)<br>
Prob(LGD = H) = 1 – Prob(LGD &lt;=M)<br>
</strong><br>
The R code is showing the detailed calculation how to convert cumulative probabilities to probabilities of interest. </p>
<pre>
cumprob_L &lt;- exp(df$LTV * (-m1$beta) + m1$Theta[1]) / (1 + exp(df$LTV * (-m1$beta) + m1$Theta[1])) 
cumprob_M &lt;- exp(df$LTV * (-m1$beta) + m1$Theta[2]) / (1 + exp(df$LTV * (-m1$beta) + m1$Theta[2])) 
prob_L &lt;- cumprob_L
prob_M &lt;- cumprob_M - cumprob_L
prob_H &lt;- 1 - cumprob_M
pred &lt;- data.frame(prob_L, prob_M, prob_H)
apply(pred, 2, mean)

#    prob_L     prob_M     prob_H 
#0.28751210 0.65679888 0.05568903 
</pre>
<p>After predicting the probability of each category, we would need another sub-model to estimate the conditional LGD for lgd_cat = “M” with either Beta or Simplex regression. (See <a rel="nofollow" href="https://statcompute.wordpress.com/2014/10/27/flexible-beta-modeling" target="_blank">https://statcompute.wordpress.com/2014/10/27/flexible-beta-modeling</a> and <a rel="nofollow" href="https://statcompute.wordpress.com/2014/02/02/simplex-model-in-r" target="_blank">https://statcompute.wordpress.com/2014/02/02/simplex-model-in-r</a>) The final LGD prediction can be formulated as<br>
<strong><br>
E(LGD|X)<br>
= Prob(Y = 0|X) * E(Y|X, Y = 0) + Prob(Y = 1|X) * E(Y|X, Y = 1) + Prob(0 &lt; Y &lt; 1|X) * E(Y|X, 0 &lt; Y &lt; 1)<br>
= Prob(Y = 1|X) + Prob(0 &lt; Y &lt; 1|X) * E(Y|X, 0 &lt; Y &lt; 1)<br>
</strong><br>
where E(Y|X, 0 &lt; Y &lt; 1) can be calculated from the sub-model. </p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://statcompute.wordpress.com/2018/01/28/modeling-lgd-with-proportional-odds-model/"> S+/R – Yet Another Blog in Statistical Computing</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/vT4rH1tRFIQ" height="1"></a></div>