<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/model-operational-losses-with-copula-regression/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://statcompute.wordpress.com/2017/08/20/model-operational-losses-with-copula-regression/"> 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>In the previous post (<a rel="nofollow" href="https://statcompute.wordpress.com/2017/06/29/model-operational-loss-directly-with-tweedie-glm" target="_blank">https://statcompute.wordpress.com/2017/06/29/model-operational-loss-directly-with-tweedie-glm</a>), it has been explained why we should consider modeling operational losses for non-material UoMs directly with Tweedie models. However, for material UoMs with significant losses, it is still beneficial to model the frequency and the severity separately. </p>
<p>In the prevailing modeling practice for operational losses, it is often convenient to assume a functional independence between frequency and severity models, which might not be the case empirically. For instance, in the economic downturn, both the frequency and the severity of consumer frauds might tend to increase simultaneously. With the independence assumption, while we can argue that same variables could be included in both frequency and severity models and therefore induce a certain correlation, the frequency-severity dependence and the its contribution to the loss distribution might be overlooked. </p>
<p>In the context of Copula, the distribution of operational losses can be considered a joint distribution determined by both marginal distributions and a parameter measuring the dependence between marginals, of which marginal distributions can be Poisson for the frequency and Gamma for the severity. Depending on the dependence structure in the data, various copula functions might be considered. For instance, a product copula can be used to describe the independence. In the example shown below, a Gumbel copula is considered given that it is often used to describe the positive dependence on the right tail, e.g. high severity and high frequency. For details, the book “Copula Modeling” by Trivedi and Zimmer is a good reference to start with. </p>
<p>In the demonstration, we simulated both frequency and severity measures driven by the same set of co-variates. Both are positively correlated with the Kendall’s tau = 0.5 under the assumption of Gumbel copula.</p>
<pre>
library(CopulaRegression)
# number of observations to simulate
n &lt;- 100
# seed value for the simulation
set.seed(2017)
# design matrices with a constant column
X &lt;- cbind(rep(1, n), runif(n), runif(n))
# define coefficients for both Poisson and Gamma regressions
p_beta &lt;- g_beta &lt;- c(3, -2, 1)
# define the Gamma dispersion
delta &lt;- 1
# define the Kendall's tau
tau &lt;- 0.5
# copula parameter based on tau
theta &lt;- 1 / (1 - tau)
# define the Gumbel Copula 
family &lt;- 4
# simulate outcomes
out &lt;- simulate_regression_data(n, g_beta, p_beta, X, X, delta, tau, family, zt = FALSE)
G &lt;- out[, 1]
P &lt;- out[, 2]
</pre>
<p>After the simulation, a Copula regression is estimated with Poisson and Gamma marginals for the frequency and the severity respectively. As shown in the model estimation, estimated parameters with related inferences are different between independent and dependent assumptions. </p>
<pre>
m &lt;- copreg(G, P, X, family = 4, sd.error = TRUE, joint = TRUE, zt = FALSE)
coef &lt;- c(&quot;_CONST&quot;, &quot;X1&quot;, &quot;X2&quot;)
cols &lt;- c(&quot;ESTIMATE&quot;, &quot;STD. ERR&quot;, &quot;Z-VALUE&quot;)
g_est &lt;- cbind(m$alpha, m$sd.alpha, m$alpha / m$sd.alpha)
p_est &lt;- cbind(m$beta, m$sd.beta, m$beta / m$sd.beta)
g_est0 &lt;- cbind(m$alpha0, m$sd.alpha0, m$alpha0 / m$sd.alpha0)
p_est0 &lt;- cbind(m$beta0, m$sd.beta0, m$beta0 / m$sd.beta0)
rownames(g_est) &lt;- rownames(g_est0) &lt;- rownames(p_est) &lt;- rownames(p_est0) &lt;- coef
colnames(g_est) &lt;- colnames(g_est0) &lt;- colnames(p_est) &lt;- colnames(p_est0) &lt;- cols

# estimated coefficients for the Gamma regression assumed dependence 
print(g_est)
#          ESTIMATE  STD. ERR   Z-VALUE
# _CONST  2.9710512 0.2303651 12.897141
# X1     -1.8047627 0.2944627 -6.129003
# X2      0.9071093 0.2995218  3.028526

# estimated coefficients for the Gamma regression assumed dependence 
print(p_est)
#         ESTIMATE   STD. ERR   Z-VALUE
# _CONST  2.954519 0.06023353  49.05107
# X1     -1.967023 0.09233056 -21.30414
# X2      1.025863 0.08254870  12.42736

# estimated coefficients for the Gamma regression assumed independence 
# should be identical to GLM() outcome
print(g_est0)
#         ESTIMATE  STD. ERR   Z-VALUE
# _CONST  3.020771 0.2499246 12.086727
# X1     -1.777570 0.3480328 -5.107478
# X2      0.905527 0.3619011  2.502140

# estimated coefficients for the Gamma regression assumed independence 
# should be identical to GLM() outcome
print(p_est0)
#         ESTIMATE   STD. ERR   Z-VALUE
# _CONST  2.939787 0.06507502  45.17536
# X1     -2.010535 0.10297887 -19.52376
# X2      1.088269 0.09334663  11.65837
</pre>
<p>If we compare conditional loss distributions under different dependence assumptions, it shows that the predicted loss with Copula regression tends to have a fatter right tail and therefore should be considered more conservative. </p>
<pre>
df &lt;- data.frame(g = G, p = P, x1 = X[, 2], x2 = X[, 3])
glm_p &lt;- glm(p ~ x1 + x2, data = df, family = poisson(log))
glm_g &lt;- glm(g ~ x1 + x2, data = df, family = Gamma(log))
loss_dep &lt;- predict(m, X, X, independence = FALSE)[3][[1]][[1]]
loss_ind &lt;- fitted(glm_p) * fitted(glm_g)
den &lt;- data.frame(loss = c(loss_dep, loss_ind), lines = rep(c(&quot;DEPENDENCE&quot;, &quot;INDEPENDENCE&quot;), each = n))
ggplot(den, aes(x = loss, fill = lines)) + geom_density(alpha = 0.5)
</pre>
<p><img data-orig-file="https://statcompute.files.wordpress.com/2017/08/loss2.png?w=456" data-orig-size="1731,1004" data-medium-file="https://statcompute.files.wordpress.com/2017/08/loss2.png?w=456?w=300" data-attachment-id="2980" data-image-meta="{" data-image-description="" src="https://statcompute.files.wordpress.com/2017/08/loss2.png?w=456" data-permalink="https://statcompute.wordpress.com/2017/08/20/model-operational-losses-with-copula-regression/loss2/" data-large-file="https://statcompute.files.wordpress.com/2017/08/loss2.png?w=456?w=1731" alt="loss2" data-image-title="loss2" sizes="(max-width: 700px) 100vw, 700px" data-comments-opened="0" class="wp-image-2980" data-recalc-dims="1"></p>
<p> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/statcompute.wordpress.com/2976/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/comments/statcompute.wordpress.com/2976/"></a> <img border="0" alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" data-recalc-dims="1"></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/2017/08/20/model-operational-losses-with-copula-regression/"> 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 alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/ib1grpA53Z0" height="1"></a></div>