spaMM reference page

spaMM is a standard R package distributed on  CRAN. It was originally designed for fitting spatial generalized linear mixed models (GLMMs), 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 A few distinctive features are highlighted below. 

Figures generated by code shown in example(seaMask) and example(mapMM)

  • It deals with several random effects with different distributions, one of which may be a Gaussian spatial effect;
  • Genetic, phylogenetic, or other given correlations are easily taken into account using the corrMatrix argument of the HLCor function;
  • It fits the Beta binomial model, negative binomial response family, and  Conway-Maxwell-Poisson (COMPoisson) response family
  • It fits models with structured residual dispersion, including residual dispersion models with random effects, and thus implements a class of "double hierarchical GLMs";
  • It includes a replacement function for glm, useful when the latter (or even glm2) fails to fit a model;
  • Its syntax is close to that of glm or [g]lmer. It includes a growing list of extractor methods derived from those in stats or nlme/lmer, and functions for inference beyond the fits, such as confint for confidence intervals of fixed-effect parameters, and predict including computation of prediction variances
  • It includes simple facilities for quickly drawing maps from model fits (as shown on the right). See here for more elaborate examples of producing maps;
  • It includes facilities for handling multinomial data.

You can download here a gentle introduction (latest version May 26, 2017) to the package.

Version 2.1.0 was released on CRAN on May 25, 2017. This page could provide updates not yet on CRAN (see installation notes below if you download such an update) but this is not the case presently. The previously released version 2.0.0 has brought some substantial improvements in terms of speed for most analyses (particularly non-spatial ones). See the NEWS for all recent changes.

spaMM was designed first to fit spatial models with dense correlation matrices. Substantial computational speed-ups for "autoregressive" models were not first considered, out of a lack of specific interest for such models. However, an efficient implementation of the conditional autoregressive (CAR) model is available, as a step towards further developments.  

Planned developments for spaMM include the implementation of simultaneous autoregressive (SAR) models, and the use of stochastic algorithms for estimation of likelihood in binary probit models. Initial development has been based on several variants of Laplace aproximations discussed in particular by Lee, Nelder, and collaborators (e.g. Lee, Nelder & Pawitan, 2006; Lee & Lee 2012; see also Molas and Lesaffre, 2010), as well as the iterative algorithms used in these works. However, the iterative algorithms are often slow and more recent versions implement alternative approaches to maximization of likelihood approximations.  

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.

Past and current contributors: François Rousset (maintainer), Jean-Baptiste Ferdy, and Alexandre Courtiol.

Funding: spaMM development benefitted from a PEPS grant from CNRS and University of Montpellier and is currently hosted within the IBC.

Installing versions obtained from this page:

Installation is exactly as for any other local tar.gz package archive, but details of this general procedure are often ignored.
Run install.packages with the highlighted options:
> install.packages(<archive name>,type="source",repos=NULL)
If this fails and you are a Windows user, then it is likely that you have not (fully) installed the Rtools. If you think you have installed the Rtools but this fails, then you probably have not set the PATH variable in the Windows environment variables (cf "Edit the path variable" here). To check that you have fully installed the Rtools, make a test by installing another package that requires compilation, e.g. lpSolveAPI, from its archive by using type="source".

This page (C) F. Rousset 2013-present

Main web page