<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/mixed-models-with-adaptive-gaussian-quadrature/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://iprogn.blogspot.com/2018/06/mixed-models-with-adaptive-gaussian.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><a rel="nofollow" href="https://i0.wp.com/4.bp.blogspot.com/-MLceO6tCqTg/WyKX2k6axlI/AAAAAAAAAKc/gKSKEUggRIQ-axKIQ3r-AArgd3Y0H80TwCEwYBhgL/s1600/hex_GLMMadaptive.png?ssl=1" target="_blank"><img border="0" src="https://i0.wp.com/4.bp.blogspot.com/-MLceO6tCqTg/WyKX2k6axlI/AAAAAAAAAKc/gKSKEUggRIQ-axKIQ3r-AArgd3Y0H80TwCEwYBhgL/s200/hex_GLMMadaptive.png?resize=450%2C600&ssl=1" data-original-width="450" width="450" data-original-height="600" data-recalc-dims="1"></a>Overview</h3>
<p>In this post, I would like to introduce my new R package <a rel="nofollow" href="https://cran.r-project.org/package=GLMMadaptive" target="_blank">GLMMadaptive</a> for fitting mixed-effects models for non-Gaussian grouped/clustered outcomes using marginal maximum likelihood.</p>
<p>Admittedly, there is a number of packages available for fitting similar models, e.g., <a rel="nofollow" href="https://cran.r-project.org/package=lme4" target="_blank">lme4</a>, <a rel="nofollow" href="https://cran.r-project.org/package=glmmsr" target="_blank">glmmsr</a>, <a rel="nofollow" href="https://cran.r-project.org/package=glmmTMB" target="_blank">glmmTMB</a>, <a rel="nofollow" href="https://cran.r-project.org/package=glmmEP" target="_blank">glmmEP</a>, and <a rel="nofollow" href="https://cran.r-project.org/package=glmmML" target="_blank">glmmML</a> among others; more information on other available packages can also be found in <a rel="nofollow" href="http://bbolker.github.io/mixedmodels-misc/glmmFAQ.html" target="_blank">GLMM-FAQ</a>. <a rel="nofollow" href="https://cran.r-project.org/package=GLMMadaptive" target="_blank">GLMMadaptive</a> differs from these packages in approximating the integrals over the random effects in the definition of the marginal log-likelihood function using an adaptive Gaussian quadrature rule, while allowing for multiple correlated random effects.</p>
<h3>An Example: Mixed Effects Logistic Regression</h3>
<p>We illustrate the use of the package in the simple case of a mixed effects logistic regression. We start by simulating some data:</p>
<p></p>
<p>We continue by fitting the mixed effects logistic regression for the longitudinal outcome <span>y</span> assuming random intercepts for the random-effects part. The primary model-fitting function in the package is the <span>mixed_model()</span>, and has four required arguments, namely,</p>
<ul>
<li><span>fixed</span>: a formula for the fixed effects, <span> </span></li>
<li><span>random:</span> a formula for the random effects, <span> </span></li>
<li><span>family</span>: a family object specifying the type of response variable, and <span> </span></li>
<li><span>data</span>: a data frame containing the variables in the previously mentioned formulas.</li>
</ul>
<p> Assuming that the package has been loaded using <span>library(“GLMMadaptive”)</span>, the call to fit the random intercepts logistic regression is:</p>
<p></p>
<p><span open>By default, 11 quadrature points are used, but this can be adjusted using the <span>nAGQ</span> control argument. We extend model <span>fm1</span> </span><code></code><span open>by also including a random slopes term; however, we assume that the covariance between the random intercepts and random slopes is zero. This is achieved by using the <span>`||`</span> </span><code></code><span open>symbol in the specification of the </span><span open><span>random </span></span><code></code><span open>argument. We fit the new model and compare it with <span>fm1</span> using the <span>anova()</span> function that performs a likelihood ratio test:</span></p>
<p><span open></span><br><span open><br></span> <span open> We further extend the model by estimating the covariance between the random intercepts and random slopes, and we use 15 quadrature points for the numerical integration:</span><br><span open><br></span> <span open><br></span></p>
<h3>Capabilities and Further Reading</h3>
<p>The package offers a wide range of methods for standard generic functions in R applicable to regression models objects and mixed models objects in particular (e.g., <span>fixef()</span>, <span>ranef()</span>, etc.); more information can be found in the <a rel="nofollow" href="https://cran.r-project.org/web/packages/GLMMadaptive/vignettes/Methods_MixMod.html" target="_blank">Methods for MixMod Objects</a> vignette. In addition, some highlights of its capabilities:</p>
<ul>
<li>It allows for user-defined family objects implementing not standardly available outcome distributions; more information can be found in the <a rel="nofollow" href="https://cran.r-project.org/web/packages/GLMMadaptive/vignettes/Custom_Models.html" target="_blank">Custom Models</a> vignette.</li>
<li>It can calculate fixed effects coefficients with a marginal / population averaged interpretation using the function <span>marginal_coefs()</span>.</li>
<li>Function <span>effectPlotData()</span> calculates predictions and confidence intervals for constructing effect plots.</li>
</ul>
<p>The development version of the package is available on the <a rel="nofollow" href="https://github.com/drizopoulos/GLMMadaptive" target="_blank">GitHub repository</a>.</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/06/mixed-models-with-adaptive-gaussian.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 alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/_1qE_LX5RMY" height="1"></a></div>