4.56 KB
Newer Older
francois's avatar
francois committed
# spaMM-distrib

francois's avatar
francois committed
Public repository for distribution of  things related to __spaMM__:
francois's avatar
francois committed

francois's avatar
francois committed
__spaMM__ is a standard R package available on CRAN (latest version: 3.7.2, 2021/02/26). It was originally designed for fitting __spa__tial generalized linear __M__ixed __M__odels, particularly the so-called geostatistical model allowing prediction in continuous space. But it is now a more general-purpose package for fitting mixed models, spatial or not, and with efficient methods for both geostatistical and autoregressive models. Its latest major addition is the ability to fit multivariate-response models. You can download here a [gentle introduction]( (latest version: 2021/02/26) to the package. 

Use a CRAN repository to install the package in an R architecture, unless you are looking for something more specific here.
francois's avatar
francois committed
See the (unofficial) [CRAN github repository]( for an archive of sources for all versions of spaMM previously published on CRAN.
francois's avatar
francois committed

francois's avatar
francois committed
<img align="right" width="200" height="200" src="">
francois's avatar
francois committed
Initial stimulus for spaMM development came from work by Lee and Nelder on h-likelihood (e.g. [Lee, Nelder & Pawitan](, 2006; [Lee & Lee]( 2012; see also [Molas and Lesaffre](, 2010), and it retains from that work several distinctive features, such as the ability to fit models with non-gaussian random effects (e.g., Beta- or Gamma-distributed), structured dispersion models (including residual dispersion models with random effects), and implementation of several variants of Laplace and PQL approximations. But it often relies on alternatives to the iterative algorithms considered by Lee and Nelder to jointly fit all model parameters, and on alternative implementations of the most expensive matrix computations. spaMM has distinct algorithms for three cases: sparse precision, sparse correlation, and dense correlation matrices, and is efficient to fit geostatistical, autoregressive, and other mixed models on large data sets. Notable features include: 

- Fitting geostatistical models with random-effect terms following the `Matern` as well as the much less known `Cauchy` correlation models, or autoregressive models described by an `adjacency` matrix or `AR1` model, or an arbitrary given precision or correlation matrix (`corrMatrix`). Conditional spatial effects can be fitted,  as in (say) `Matern(female|...)+Matern(male|...)` to fit distinct random effects for females and males.
- A further class of spatial correlation models, "Interpolated Markov Random Fields" (`IMRF`) covers widely publicized approximations of Matérn models ([Lindgren et al. 2011]( and the multiresolution model of [Nychka et al. 2015]( 
- Allowed response families include zero-truncated variants of the Poisson and negative binomial, and the Conway-Maxwell-Poisson (`COMPoisson`) family;
- All the above features combined in multivariate-response models. Previously, more experimental facilities have been available for handling multinomial data only;
- A replacement function for `glm`, useful when the latter (or even `glm2`) fails to fit a model;
- A syntax close to that of `glm` or [`g`]`lmer`. It includes a growing list of extractor methods similar to those in `stats` or `nlme`/`lmer`, and functions for inference beyond the fits, such as `confint()` for confidence intervals of fixed-effect parameters, `predict()` and related functions for point prediction and prediction variances, and compatibility with functions from other packages such as `multcomp::glht()` (see `help("post-fit")`); 
francois's avatar
francois committed
- Simple facilities for quickly drawing maps from model fits, using only base graphic functions. See [here]( for more elaborate examples of producing maps.

The performance of Laplace approximations for spatial GLMMs was assessed in :
    Rousset F., Ferdy J.-B. (2014) [Testing environmental and genetic effects in the presence of spatial autocorrelation]( Ecography, 37: 781-790.
Also available here is the [Supplementary Appendix G]( from that paper, including comparisons with a trick commonly, but uncritically, used to constrain the functions `lmer` and `glmmPQL` to analyse spatial models.