<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-frequency-outcomes-with-ordinal-models/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://statcompute.wordpress.com/2018/09/10/modeling-frequency-outcomes-with-ordinal-models/"> 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>When modeling frequency outcomes, we often need to go beyond the standard Poisson regression due to the strict distributional assumption and to consider more flexible alternatives. In general, there are two broad categories of modeling approaches in light of practical concerns about frequency outcomes. </p>
<p>The first category of models are mainly intended to address the excessive variance, namely over-dispersion, and are including hurdle, zero-inflated Poisson, and latent class Poisson models (<a rel="nofollow" href="https://statcompute.wordpress.com/2012/11/03/another-class-of-risk-models" target="_blank">https://statcompute.wordpress.com/2012/11/03/another-class-of-risk-models</a>). This class of models assume the mixture of distributions and often require to estimate multiple sets of parameters for different distributions, which might lead to other potential issues, such as variable selection, estimation convergence, or model interpretation. For instance, the hurdle model consists of a logistic regression and a truncated Poisson regression and therefore requires two sets of parameters. </p>
<p>The second category of models are more general to accommodate both over-dispersion and under-dispersion by incorporating complicated variance functions and are including generalized Poisson, double Poisson, hyper-Poisson, and Conway-Maxwell Poisson models (<a rel="nofollow" href="https://statcompute.wordpress.com/2016/11/27/more-about-flexible-frequency-models" target="_blank">https://statcompute.wordpress.com/2016/11/27/more-about-flexible-frequency-models</a>). This class of models require to simultaneously estimate both mean and variance functions with separate sets of parameters and often suffer from convergence difficulties in the model estimation. All four mentioned above are distributions with two parameters, on which mean and variance functions are jointly determined. Due to the complexity, these models are not even widely used in the industry. </p>
<p>In addition to above-mentioned models with the intention of directly addressing the variance issue, another possibility is to steer away from the problem by using ordinal models. As pointed out by Agresti (2010), “Even when the response variable is interval scale rather than ordered categorical, ordinal models can still be useful. One such case occurs when the response outcome is a count but when standard sampling models for counts, such as the Poisson, do not apply”. An example is that customers with many delinquencies are hardly observable in certain consumer banking portfolios. The similar is also true for insurance customers with a high count of auto claims. In both scenarios, upper limits for frequency outcomes have been enforced by industry practices or corporate policies, putting the application of frequency models in doubt. Additionally, the over-parameterization also makes complicated frequency models less attractive empirically. In such cases, ordinal models, such as Proportional Odds models, are worth considering. </p>
<p>The demonstration below will show how to estimate the frequency of major derogatory reports for credit card customers with a Proportional Odds model. Before the model estimation, it is helpful to examine the distribution of the response variable and shown that nearly 90% cardholders have no major derogatory and the maximum number of incidents is 6, implying that the standard Poisson regression might not be sufficient. </p>
<pre>
df &lt;- read.csv(&quot;Downloads/credit_count.txt&quot;)
df1 &lt;- df[which(df$CARDHLDR == 1), ]
freq &lt;- table(df1$MAJORDRG)
#    0    1    2    3    4    5    6 
# 9361  855  220   47   13    2    1 
</pre>
<p>Estimating an ordinal model for the frequency outcome is straightforward in R with the rms::orm function. In the model output, different intercepts are used to differentiate different levels of the frequency outcome. Therefore, there are 6 different intercepts in the Proportional Odds model to differentiate 7 levels of derogatory reports from 0 to 6. After the model estimation, we can aggregate the probability of each frequency outcome to derive the conditional distribution of derogatory reports. </p>
<pre>
Y &lt;- &quot;MAJORDRG&quot;
X &lt;- c(&quot;AGE&quot;, &quot;ACADMOS&quot;, &quot;ADEPCNT&quot;, &quot;MINORDRG&quot;, &quot;INCPER&quot;, &quot;LOGSPEND&quot;)
fml &lt;- as.formula(paste(Y, paste(X, collapse = &quot; + &quot;), sep = &quot; ~ &quot;))
m1 &lt;- rms::orm(fml, data = df1, family = logistic)
m1.pred &lt;- data.frame(predict(m1, type = &quot;fitted.ind&quot;))
dist1 &lt;- sapply(m1.pred, sum) 
</pre>
<p>For the comparison purpose, a standard Poisson regression is also estimated with the conditional distribution derived below. </p>
<pre>
m2 &lt;- glm(fml, data = df1, family = poisson(link = &quot;log&quot;))
m2.pred &lt;- predict(m2, type = &quot;response&quot;)
dist2 &lt;- apply(sapply(0:6, function(i) dpois(i, m2.pred)), 2, sum)
</pre>
<p>At last, we would compare the observed distribution with conditional distributions from two different models. From the distributional comparison, it is clear that the Proportional Odds model does a better job than the standard Poisson model. (Since the code can not be displayed correctly, I saved it as the image.)<br>
<img data-orig-file="https://statcompute.files.wordpress.com/2018/09/screenshot-from-2018-09-10-22-41-42.png?w=456" data-orig-size="1422,124" data-medium-file="https://statcompute.files.wordpress.com/2018/09/screenshot-from-2018-09-10-22-41-42.png?w=456?w=300" data-attachment-id="3231" data-image-meta="{" data-image-description="" src="https://statcompute.files.wordpress.com/2018/09/screenshot-from-2018-09-10-22-41-42.png?w=456" data-permalink="https://statcompute.wordpress.com/2018/09/10/modeling-frequency-outcomes-with-ordinal-models/screenshot-from-2018-09-10-22-41-42/" data-large-file="https://statcompute.files.wordpress.com/2018/09/screenshot-from-2018-09-10-22-41-42.png?w=456?w=1422" alt="Screenshot from 2018-09-10 22-41-42" data-image-title="Screenshot from 2018-09-10 22-41-42" sizes="(max-width: 1200px) 100vw, 1200px" data-comments-opened="0" class="wp-image-3231" data-recalc-dims="1"></p>
<p><img data-orig-file="https://statcompute.files.wordpress.com/2018/09/rplot.png?w=456" data-orig-size="1000,500" data-medium-file="https://statcompute.files.wordpress.com/2018/09/rplot.png?w=456?w=300" data-attachment-id="3227" data-image-meta="{" data-image-description="" src="https://statcompute.files.wordpress.com/2018/09/rplot.png?w=456" data-permalink="https://statcompute.wordpress.com/2018/09/10/modeling-frequency-outcomes-with-ordinal-models/rplot-2/" data-large-file="https://statcompute.files.wordpress.com/2018/09/rplot.png?w=456?w=1000" alt="Rplot" data-image-title="Rplot" sizes="(max-width: 1000px) 100vw, 1000px" data-comments-opened="0" class="wp-image-3227" 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/2018/09/10/modeling-frequency-outcomes-with-ordinal-models/"> 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/YSXUBo4ezuo" height="1"></a></div>