glmmTMB
is an R package for fitting generalized linear mixed models (GLMMs) and extensions, built on Template Model Builder, which is in turn built on CppAD and Eigen. It is intended to handle a wide range of statistical distributions (Gaussian, Poisson, binomial, negative binomial, Beta ...) as well as model extensions such as zero-inflation, heteroscedasticity, and autocorrelation. Fixed and random effects models can be specified for the conditional and zero-inflated components of the model, as well as fixed effects models for the dispersion parameter.
r-sig-mixed-models@r-project.org
for general questions aboutglmmTMB
usage and mixed models- https://github.com/glmmTMB/glmmTMB/issues for bug, infelicity, and wishlist reporting
- https://groups.google.com/forum/#!forum/tmb-users for TMB-specific questions
- maintainer e-mail only for urgent/private communications
glmmTMB
is on CRAN, so you can install the latest release version in the usual way, i.e. install.packages("glmmTMB")
.
When loading glmmTMB
you may encounter this message:
Package version inconsistency detected.
TMB was built with Matrix version [xxxx]
Current Matrix version is [yyyy]
Please re-install 'TMB' from source or restore original 'Matrix' package
This may happen because you have installed a new version of glmmTMB
from CRAN but haven't updated the Matrix
package to its newest version. If this is the case, just use update.packages()
(to update all of your packages) or install.packages("Matrix")
(to install just the latest version of Matrix
from CRAN).
Alternately (slightly more problematically), this may happen because you've updated the Matrix
package to a newer version that was published on CRAN more recently than the latest CRAN version of TMB
. Installing a new binary version of TMB
from CRAN (i.e., via update.packages()
or install.packages("TMB")
on Windows or MacOS) probably won't help, because the binary package on CRAN will have been built with the older version.
To re-install TMB
from source, or to restore an older version of Matrix
, you will need to have developer tools (compilers etc.) installed; these are not R packages, but additional packages and libraries for your operating system. You can try devtools::dr_devtools()
to see if you have them already; if not, see the RStudio devtools docs for links to download and install them.
At this point, if you're lucky, install.packages("TMB",type="source")
will take care of everything.
If you're unlucky (e.g. you're using MacOS and originally installed R from a binary package), you may have some more work to do.
- if you get errors about
library not found for -lgfortran
orlibrary not found for -lquadmath
you need to follow these instructions to update your Fortran compilers. - if you get errors about
unsupported option '-fopenmp'
you need to turn off OpenMP compilation by adding the lineSHLIB_OPENMP_CFLAGS=
to your~/.R/Makevars
file. If you've already done step #1 this file will already exist; use a text editor to add the line above. Otherwise, you need to create it.
After updating your compilers (if necessary) and turning off OpenMP compilation, re-try the installation from source.
If you opt to restore an older version of Matrix
, try devtools::install_version("Matrix","[xxxx]")
, where [xxxx]
is the version of Matrix
shown in the original error message. This will also require installation from source.
If all else fails you can ask a maintainer to provide a binary version of the TMB
package that works for your OS and Matrix
version.
You can install the most recent development version of glmmTMB
via
devtools::install_github("glmmTMB/glmmTMB/glmmTMB")
(this string denotes "Github user glmmTMB
, repository glmmTMB
, subdirectory glmmTMB
"). If the install fails at the vignette-building step, try specifying build_vignettes=FALSE
within the install_github
call. You'll need to have development tools (compilers etc.) installed: devtools::dr_devtools()
and the RStudio devtools docs should help. Installing the source version will ensure that you get the very latest version of the package.