<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/marginal-effects-for-negative-binomial-mixed-effects-models-glmer-nb-and-glmmtmb-rstats/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://strengejacke.wordpress.com/2017/08/27/marginal-effects-for-negative-binomial-mixed-effects-models-glmer-nb-and-glmmtmb-rstats/"> R – Strenge Jacke!</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Here’s a small preview of forthcoming features in the <a rel="nofollow" href="https://github.com/strengejacke/ggeffects" target="_blank">ggeffects-package</a>, which are already available in the GitHub-version: For marginal effects from models fitted with <code>glmmTMB()</code> or <code>glmer()</code> resp. <code>glmer.nb()</code>, confidence intervals are now also computed.</p>
<p>If you want to test these features, simply install the package from GitHub:<br>
<code>
<pre>library(devtools)
devtools::install_github(&quot;strengejacke/ggeffects&quot;)</pre>
<p></p>
<p>Here are three examples:<br>
<code>
<pre>library(glmmTMB)
library(lme4)
library(ggeffects)
data(Owls)

m1 &lt;- glmmTMB(SiblingNegotiation ~ SexParent + ArrivalTime + (1 | Nest), data = Owls, family = nbinom1)
m2 &lt;- glmmTMB(SiblingNegotiation ~ SexParent + ArrivalTime + (1 | Nest), data = Owls, family = nbinom2)
m3 &lt;- glmer.nb(SiblingNegotiation ~ SexParent + ArrivalTime + (1 | Nest), data = Owls)
m4 &lt;-
  glmmTMB(
    SiblingNegotiation ~ FoodTreatment + ArrivalTime + SexParent + (1 | Nest),
    data = Owls,
    ziformula =  ~ 1,
    family = list(family = &quot;truncated_poisson&quot;, link = &quot;log&quot;)
  )</pre>
<p></p>
<p><code>
<pre>pr1 &lt;- ggpredict(m1, c(&quot;ArrivalTime&quot;, &quot;SexParent&quot;))
plot(pr1)</pre>
<p></p>
<p><a rel="nofollow" href="https://strengejacke.files.wordpress.com/2017/08/meci1.png" target="_blank"><img data-orig-file="https://strengejacke.files.wordpress.com/2017/08/meci1.png" data-orig-size="800,600" data-medium-file="https://strengejacke.files.wordpress.com/2017/08/meci1.png?w=300" data-attachment-id="1389" data-image-meta="{" data-image-description="" src="https://strengejacke.files.wordpress.com/2017/08/meci1.png?w=450&h=567&fit=756%2C567" data-permalink="https://strengejacke.wordpress.com/2017/08/27/marginal-effects-for-negative-binomial-mixed-effects-models-glmer-nb-and-glmmtmb-rstats/meci1/" data-large-file="https://strengejacke.files.wordpress.com/2017/08/meci1.png?w=450&amp;h=567&amp;fit=756%2C567" alt="" data-image-title="meci1" sizes="(max-width: 756px) 100vw, 756px" data-comments-opened="1" class="wp-image-1389" data-recalc-dims="1"></a></p>
<p><code>
<pre>pr2 &lt;- ggpredict(m2, c(&quot;ArrivalTime&quot;, &quot;SexParent&quot;))
plot(pr2)</pre>
<p></p>
<p><a rel="nofollow" href="https://strengejacke.files.wordpress.com/2017/08/mpci2.png" target="_blank"><img data-orig-file="https://strengejacke.files.wordpress.com/2017/08/mpci2.png" data-orig-size="800,600" data-medium-file="https://strengejacke.files.wordpress.com/2017/08/mpci2.png?w=300" data-attachment-id="1390" data-image-meta="{" data-image-description="" src="https://strengejacke.files.wordpress.com/2017/08/mpci2.png?w=450&h=567&fit=756%2C567" data-permalink="https://strengejacke.wordpress.com/2017/08/27/marginal-effects-for-negative-binomial-mixed-effects-models-glmer-nb-and-glmmtmb-rstats/mpci2/" data-large-file="https://strengejacke.files.wordpress.com/2017/08/mpci2.png?w=450&amp;h=567&amp;fit=756%2C567" alt="" data-image-title="mpci2" sizes="(max-width: 756px) 100vw, 756px" data-comments-opened="1" class="wp-image-1390" data-recalc-dims="1"></a></p>
<p><code>
<pre>pr3 &lt;- ggpredict(m3, c(&quot;ArrivalTime&quot;, &quot;SexParent&quot;))
plot(pr3)</pre>
<p></p>
<p><a rel="nofollow" href="https://strengejacke.files.wordpress.com/2017/08/meci3.png" target="_blank"><img data-orig-file="https://strengejacke.files.wordpress.com/2017/08/meci3.png" data-orig-size="800,600" data-medium-file="https://strengejacke.files.wordpress.com/2017/08/meci3.png?w=300" data-attachment-id="1391" data-image-meta="{" data-image-description="" src="https://strengejacke.files.wordpress.com/2017/08/meci3.png?w=450&h=567&fit=756%2C567" data-permalink="https://strengejacke.wordpress.com/2017/08/27/marginal-effects-for-negative-binomial-mixed-effects-models-glmer-nb-and-glmmtmb-rstats/meci3/" data-large-file="https://strengejacke.files.wordpress.com/2017/08/meci3.png?w=450&amp;h=567&amp;fit=756%2C567" alt="" data-image-title="meci3" sizes="(max-width: 756px) 100vw, 756px" data-comments-opened="1" class="wp-image-1391" data-recalc-dims="1"></a></p>
<p><code>
<pre>pr4 &lt;- ggpredict(
  m4, 
  c(&quot;FoodTreatment&quot;, &quot;ArrivalTime [21,24,30]&quot;, &quot;SexParent&quot;)
)
plot(pr4)</pre>
<p></p>
<p><a rel="nofollow" href="https://strengejacke.files.wordpress.com/2017/08/meci5.png" target="_blank"><img data-orig-file="https://strengejacke.files.wordpress.com/2017/08/meci5.png" data-orig-size="800,600" data-medium-file="https://strengejacke.files.wordpress.com/2017/08/meci5.png?w=300" data-attachment-id="1398" data-image-meta="{" data-image-description="" src="https://strengejacke.files.wordpress.com/2017/08/meci5.png?w=450&h=567&fit=756%2C567" data-permalink="https://strengejacke.wordpress.com/2017/08/27/marginal-effects-for-negative-binomial-mixed-effects-models-glmer-nb-and-glmmtmb-rstats/meci5/" data-large-file="https://strengejacke.files.wordpress.com/2017/08/meci5.png?w=450&amp;h=567&amp;fit=756%2C567" alt="" data-image-title="meci5" sizes="(max-width: 756px) 100vw, 756px" data-comments-opened="1" class="wp-image-1398" data-recalc-dims="1"></a></p>
<p>The code to calculate confidence intervals is based on the <a rel="nofollow" href="http://bbolker.github.io/mixedmodels-misc/glmmFAQ.html" target="_blank">FAQ provided from Ben Bolker</a>. Here is another example, that reproduces <a rel="nofollow" href="http://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#lme4" target="_blank">this plot</a> (note, since <code>age</code> is numeric, <code>ggpredict()</code> produces a straight line, and not points with error bars).</p>
<p><code>
<pre>library(nlme)
data(Orthodont)
m5 &lt;- lmer(distance ~ age * Sex + (age|Subject), data = Orthodont)
pr5 &lt;- ggpredict(m5, c(&quot;age&quot;, &quot;Sex&quot;))
plot(pr5)</pre>
<p></p>
<p><a rel="nofollow" href="https://strengejacke.files.wordpress.com/2017/08/meci4.png" target="_blank"><img data-orig-file="https://strengejacke.files.wordpress.com/2017/08/meci4.png" data-orig-size="800,600" data-medium-file="https://strengejacke.files.wordpress.com/2017/08/meci4.png?w=300" data-attachment-id="1394" data-image-meta="{" data-image-description="" src="https://strengejacke.files.wordpress.com/2017/08/meci4.png?w=450&h=567&fit=756%2C567" data-permalink="https://strengejacke.wordpress.com/2017/08/27/marginal-effects-for-negative-binomial-mixed-effects-models-glmer-nb-and-glmmtmb-rstats/meci4/" data-large-file="https://strengejacke.files.wordpress.com/2017/08/meci4.png?w=450&amp;h=567&amp;fit=756%2C567" alt="" data-image-title="meci4" sizes="(max-width: 756px) 100vw, 756px" data-comments-opened="1" class="wp-image-1394" data-recalc-dims="1"></a></p>
<p> Tagged: <a rel="nofollow" href="https://strengejacke.wordpress.com/tag/data-visualization/" target="_blank">data visualization</a>, <a rel="nofollow" href="https://strengejacke.wordpress.com/tag/ggplot/" target="_blank">ggplot</a>, <a rel="nofollow" href="https://strengejacke.wordpress.com/tag/r/" target="_blank">R</a>, <a rel="nofollow" href="https://strengejacke.wordpress.com/tag/rstats/" target="_blank">rstats</a>, <a rel="nofollow" href="https://strengejacke.wordpress.com/tag/sjplot/" target="_blank">sjPlot</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/strengejacke.wordpress.com/1388/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/comments/strengejacke.wordpress.com/1388/"></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://strengejacke.wordpress.com/2017/08/27/marginal-effects-for-negative-binomial-mixed-effects-models-glmer-nb-and-glmmtmb-rstats/"> R – Strenge Jacke!</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/C-hTEgl_Fy4" height="1"></a></div></code></code></code></code></code></code></code>