bioRxivEcology
sdmTMB: an R package for fast, flexible, and user-friendly generalized linear mixed effects models with spatial and spatiotemporal random fields
S. C. Anderson, E. J. Ward, P. A. English, L. A. K. Barnett, J. T. Thorson
Abstract
Geostatistical spatial or spatiotemporal data are common across scientific fields. However, appropriate models to analyse these data, such as generalised linear mixed effects models (GLMMs) with Gaussian Markov random fields (GMRFs), are computationally intensive and challenging for many users to implement. Here, we introduce the R package sdmTMB, which extends the flexible interface familiar to users of lme4, glmmTMB, and mgcv to include spatial and spatiotemporal latent GMRFs using an SPDE-(stochastic partial differential equation) based approach. SPDE matrices are constructed with fmesher and estimation is conducted via maximum marginal likelihood with TMB or via Bayesian inference with tmbstan and rstan. We describe the model and explore case studies that illustrate sdmTMBs flexibility in implementing penalised smoothers, non-stationary processes (time-varying and spatially varying coefficients), hurdle models, cross-validation and anisotropy (directionally dependent spatial correlation). Finally, we compare the functionality, speed, and interfaces of related software, demonstrating that sdmTMB can be an order of magnitude faster than R-INLA. We hope sdmTMB will help open this useful class of models to a wider field of geostatistical analysts.
Reproducibility ledger
Nobody has reported trying to reproduce this paper yet. Did you replicate an experiment or run the code? Your report saves the next lab a week.
Sign in to file a reproducibility report.
Related papers
- Modeling Zero-Inflated Count Data With glmmTMB
Mollie E. Brooks, Kasper Kristensen, … Benjamin M. Bolker·bioRxiv·May 1, 2017
- jsdmstan: An R package for fitting joint species distribution models in Stan
Fiona M. Seaton·bioRxiv·Nov 10, 2025
- tidysdm: leveraging the flexibility of tidymodels for Species Distribution Modelling in R
M. Leonardi, M. Colucci, … A. Manica·bioRxiv·Jul 24, 2023
- sabinaMBM: An R package for Multiscale Bayesian species distribution Modelling using INLA
Jennifer Morales‐Barbero, Virgilio Gómez‐Rubio, … Rubén G. Mateo·bioRxiv·Sep 18, 2026
- Efficient Estimation of Large-Scale Spatial Capture-Recapture Models
D. Turek, C. Milleret, … P. de Valpine·bioRxiv·May 7, 2020
- Diffusion-enhanced spatio-temporal models for estimating spatial expansion
Haiqing Wu, James T. Thorson, Yi Chang·bioRxiv·Sep 22, 2026