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
yis the response,
1represents an intercept,
0omits an intercept,
x1is a covariate with a constant effect, and
x2is 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").
residuals()methods. The residuals are randomized-quantile residuals similar to those implemented in the DHARMa package. The
predict()function can take a
newdataargument similar to
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
the most complete examples. There is also a simulation function
with some examples. There are some vignettes you can see if you build
devtools::install_github("pbs-assess/sdmTMB", build_vignettes = TRUE) or look