Is it possible to fit a GAMM(Generalized Additive Mixed Model) for zero-inflated data in R?

If not, is it possible to fit a GAM(Generalized Additive Model) for zero-inflated data with a negative binomial or quasi Poisson distribution in R? (I found COZIGAM::zigam and mgcv:ziP functions for Poisson distribution)


2 Answers 2


In addition to mgcv and its zero-inflated Poisson families (ziP() and ziplss()), you might also look at the brms package by Paul-Christian Bürkner. It can fit distribution models (where you model more than just the mean, in your case the zero-inflation component of the model can be modelled as a function of covariates just like the count function).

You can include smooths in any of the linear predictors (for the mean/count, zero-inflation part, etc) via s() and t2() terms for simple 1-d or isotropic 2-d splines, or anisotropic tensor product splines respectively. It has support for zero-inflated binomial, Poisson, negative binomial, and beta distributions, plus zero-one-inflated beta distributions. It also has hurdle models for Poisson and negative binomial responses (where the count part of the model is a truncated distribution so as to not produce further zero counts).

brms fits these models using STAN, so they are fully Bayesian, but this will require you to learn a new set of interfaces to extract relevant information. That said, there are several packages offering support functions for just this task, and brms has helper functions written that utilise these secondary packages. You'll need to get STAN installed and you'll need a C++ compiler as brms compiles the model as defined using R into STAN code for evalutation.


The glmmTMB package offers this and is described in a recent bioRxiv paper: Brooks et al. (2017). Modeling Zero-Inflated Count Data with glmmTMB, bioRxiv, doi:10.1101/132753.

Gavin Simpson also has a nice blog post that compares glmmTMB with mgcv for this purpose: Fitting count and zero-inflated count GLMMs with mgcv.

  • 1
    $\begingroup$ +1 Thanks for the link to my blog post. That was a fun, distracting afternoon playing with new pkgs. $\endgroup$ Commented Aug 3, 2017 at 17:33
  • $\begingroup$ Thanks also for pointing to brms which indeed is very nice and flexible. Together with Niki Umlauf I have also been planning to write some count families for bamlss to get some further flexible regression features... but so far we didn't get round to count data distributions. $\endgroup$ Commented Aug 3, 2017 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.