Skip to content
🌐 An R package for spatial and spatiotemporal GLMMs with TMB
R C++
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
data-raw Update internal grid to have all years Feb 27, 2019
data Update internal grid to have all years Feb 27, 2019
inst Move how many knots vignette (not quite correct) Jun 25, 2019
src Standardize predict column names; default to data.frame output #7 Apr 24, 2019
.Rbuildignore Update ignore files Apr 2, 2019
.travis.yml Update .travis.yml Apr 8, 2019
DESCRIPTION Standardize predict column names; default to data.frame output #7 Apr 24, 2019
NAMESPACE Add beta family Apr 23, 2019
README.Rmd Tweak readme Aug 8, 2019 Tweak readme Aug 8, 2019
codecov.yml Coverage and other badges Apr 1, 2019


Travis build status Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. Coverage status

The sdmTMB package implements spatiotemporal predictive-process GLMMs (Generalized Linear Mixed Effects Models) using Template Model Builder (TMB), R-INLA, and Gaussian Markov random fields. One common application is for spatial or spatiotemporal species distribution models (SDMs).


You can install sdmTMB with:




  • Fits GLMMs with spatial, spatiotemporal, spatial and spatiotemporal, or AR1 spatiotemporal Gaussian Markov random fields with TMB. It can also fit spatially-varying trends through time as a random field.
  • Uses formula interfaces for fixed effects and any time-varying effects (dynamic regression) (e.g. formula = y ~ 1 + x1, time_varying = ~ 0 + x2), where y is the response, 1 represents an intercept, 0 omits an intercept, x1 is a covariate with a constant effect, and x2 is a covariate with a time-varying effect.
  • Uses a family(link) format similar to glm(), lme4, or glmmTMB. This includes Gaussian, Poisson, negative binomial, gamma, binomial, lognormal, Student-t, and Tweedie distributions with identity, log, inverse, and logit links. E.g. family = tweedie(link = "log").
  • Has predict() and residuals() methods. The residuals are randomized-quantile residuals similar to those implemented in the DHARMa package. The predict() function can take a newdata argument similar to lm() or glm() etc. The predictions are bilinear interpolated predictive-process predictions (i.e. they make smooth pretty maps).
  • Includes functionality for estimating the centre of gravity or total biomass by time step for index standardization.
  • Implements multi-phase estimation for speed.
  • Can optionally allow for anisotropy in the random fields (spatial correlation that is directionally dependent).
  • Can generate an SPDE predictive-process mesh based on a clustering algorithm and R-INLA or can take any standard R-INLA mesh created externally as input.


The main function is sdmTMB(). See ?sdmTMB and ?predict.sdmTMB for the most complete examples. There is also a simulation function ?sim with some examples. There are some vignettes you can see if you build with devtools::install_github("pbs-assess/sdmTMB", build_vignettes = TRUE) or look here.

You can’t perform that action at this time.