spaMM reference page

spaMM is a standard R package distributed on CRAN (latest version: 2.5.0, 2018/09/28). 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 notYou can download here a gentle introduction (latest version 2018/09/30) to the package. Version 2.5.0 fills several major gaps of previous versions, e.g. procedures for evaluating prediction variance in models with several random effects, and appropriate procedures for random-coefficients models with more than two correlated coefficients. See the NEWS for all recent changes.

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

    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.

    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-binomial model), structured dispersion models (including residual dispersion models with random effects), and implementation of several variants of Laplace and PQL approximations. But it increasingly 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 increasingly competitive 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);
  • A growing list of response families is handled, including zero-truncated variants of the Poisson and negative binomial, and Conway-Maxwell-Poisson (COMPoisson) family; 
  • 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 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
  • Simple facilities for quickly drawing maps from model fits (as shown on this page). See here for more elaborate examples of producing maps;
  • Facilities for handling multinomial data.
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.

Planned extensions of spaMM include the use of stochastic algorithms for estimation of likelihood in binary probit models, and faster algorithms for LMMs without spatial random effects.

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 has been 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