spaMM reference page

spaMM is a standard R package distributed on  CRAN. It was originally designed for fitting spatial generalized linear mixed models (GLMMs), but is now a more general-purpose package for fitting mixed models, spatial or not

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). For example, a mixed-model with a random effect R affecting a negative binomial response can be fitted as a model with Poisson response, a gamma-distributed random effect, and the random effect R;
  • Genetic, phylogenetic, or other given correlations are easily taken into account using the corrMatrix argument of the HLCor function;
  • It fits nested effects; it fits random-slope models including the covariation between intercept and slope effects if these are Gaussian; 
  • It includes the Beta binomial, negative binomial, or GLMs with structured dispersion as special cases;  
  • 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
  • It includes facilities for drawing maps (as shown on the right);
  • It includes facilities for handling multinomial data.

Version 1.6.2 was released on CRAN on Nov. 1, 2015. See the NEWS for recent changes. You can download here a gentle introduction (latest version Nov. 1, 2015) to the package. 

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.  

spaMM was designed first to fit spatial models with dense correlation matrices and therefore does not always take advantage of sparse matrix structures. Likewise, 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 now 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 binry probit models. The currently implemented fitting methods are 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). The performance of these methods 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 used to constrain the functions lmer and glmmPQL to analyse spatial models.

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 with the archive of another package that requires compilation, e.g. on the downloaded archive of the lpSolveAPI package.

Funding: spaMM development benefitted from a PEPS grant from CNRS and universities Montpellier 1 & 2 and is currently hosted within the IBC.

spaMM (C) François Rousset (CNRS & University Montpellier 2) & Jean-Baptiste Ferdy (University of Toulouse) 2013-present.

This page (C) F. Rousset 2013-present

Main web page