<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/zero-inflated-poisson-and-negative-binomial-models-with-glmmadaptive/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://iprogn.blogspot.com/2018/08/zero-inflated-poisson-and-negative.html"> iProgn: Interactive Prediction Tools based on Joint Models</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h3>Clustered/Grouped Count Data</h3>
<p>Often cluster/grouped count data exhibit extra zeros and over-dispersion. To account for these features, Poisson and negative binomial mixed effects models with an extra zero-inflation part are used. These models entail a logistic regression model for the extra zeros, and a Poisson or negative binomial model for the remaining zeros and the positive counts. In both models, random effects are included to account for the correlations in the repeated measurements.</p>
<p>Estimation under maximum likelihood is challenging due to the high dimension of the random effects vector. In this post, we will illustrate how to estimate the parameters of such models using the package <a rel="nofollow" href="https://drizopoulos.github.io/GLMMadaptive/" target="_blank">GLMMadaptive</a> that uses the adaptive Gaussian quadrature rule to approximate the integrals over the random effects. The function in the package that fits these models is <span>mixed_model()</span>. The user defines the type of model using the <span>family</span> argument. Arguments <span>fixed</span> and <span>random</span> specify the R formulas for the fixed- and random-effects parts of the model for the remaining zeros and the positive counts, and arguments <span>zi_fixed</span> and <span>zi_random</span> specify the formulas for the fixed- and random-effects parts for the extra zeros part.</p>
<h3>Simulate Zero-Inflated Negative Binomial Data</h3>
<p>To illustrate the use of function <span>mixed_model()</span> to fit these models, we start by simulating longitudinal data from a zero-inflated negative binomial distribution:</p>
<p></p>
<h3><span>Zero-Inflated Poisson Mixed Effects Model</span></h3>
<p>A zero-inflated Poisson mixed model with only fixed effects in the zero part is fitted with the following call to <span>mixed_model()</span> that specifies the <span>zi.poisson()</span> family object in the <span>family</span> argument:</p>
<p><br>  <br>Only the log link is currently available for the non-zero part and the logit link for the zero part. Hence, the estimated fixed effects for the two parts are interpreted accordingly. We extend <span>fm1</span> by also allowing for random intercepts in the zero part. We should note that by default the random intercept of the non-zero part is correlated with the random intercept from the zero part:</p>
<p></p>
<p>We test if we need the extra random effect using a likelihood ratio test:</p>
<p> </p>
<p><code></code></p>
<h3>Zero-Inflated Negative Binomial Mixed Effects Model</h3>
<p>We continue with the same data, but we now take into account the potential over-dispersion in the data using a zero-inflated negative binomial model. To fit this mixed model we use an almost identical syntax to what we just did above – the only difference is that we now specify as family the zi.negative.binomial() object:</p>
<p></p>
<p>Similarly to <span>fm1</span>, in <span>gm1</span> we specified only fixed effects for the logistic regression for the zero part. We now compare this model with the zero-inflated Poisson model that allowed for a random intercept in the zero part. The comparison can be done with the <span>anova()</span> method; because the two models are not nested, we set <span>test = FALSE</span> in the call to <span>anova()</span>, i.e.:</p>
<p></p>
<p>We observe that accounting for the over-dispersion seems to better improve the fit than including the random intercepts term in the zero part.</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="http://iprogn.blogspot.com/2018/08/zero-inflated-poisson-and-negative.html"> iProgn: Interactive Prediction Tools based on Joint Models</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/mDnroU2nJck" height="1"></a></div>