Bayesian Spatial Autocorrelation

Statistics
Introduced by
Besag, York & Mollie
Year
1991
Type
Bayesian hierarchical spatial model
Family
GIS / spatial

What does it do?

Bayesian Spatial Autocorrelation is a Bayesian hierarchical model of the Besag-York-Mollié (BYM) type for areal count or rate data.

It is a smoothing model for area-level risk and is not a test of global or local spatial autocorrelation. Spatial dependence enters through a Conditional Autoregressive (CAR) prior on area-level random effects, which encodes the expectation that neighboring areas tend to be more similar than distant ones. Posterior inference is typically carried out with MCMC or with the approximate method INLA, and the model is most often used for disease mapping and other small-area estimation problems.

The intuition behind the method

A test such as Moran's I asks whether values cluster across space and returns one summary statistic with a p-value. The model described here asks a different question. It treats the spatially structured part of each area's risk as a latent random field, gives that field a CAR prior, and updates the prior with the observed counts. The output is a posterior distribution for each area's relative risk and for the variance parameters of the random effects, so uncertainty about local estimates is reported alongside the estimates themselves. The model is therefore better understood as a smoothing model for area-level rates than as a test of spatial autocorrelation.

History

The model was introduced by Besag, York and Mollié (1991), who combined a CAR prior for spatially structured effects with an independent heterogeneity term; this combination is known as the BYM model. The 1991 paper, titled 'Bayesian image restoration, with two applications in spatial statistics', presents the framework together with two applications in spatial statistics. The model was later applied to disease mapping and other areal problems, and implementations such as R-INLA made posterior approximation practical for larger datasets.

When to use it

Choose this model when your data are counts or rates for a set of areas with a defined neighbor structure, such as administrative units with a contiguity matrix, along with known expected counts or population denominators. It is particularly relevant when individual areas have small counts, so raw rates are unstable, and the goal is smoothed area-level estimates with uncertainty. Do not use it when the units have no meaningful adjacency, or when the data are point locations that call for a continuous-surface geostatistical model. If you only need to check whether clustering exists in the data, a global Moran's I test answers that question with far less computation. Avoid the model when you cannot justify the choice of W or the priors, because the results depend on both.

Limitations and considerations

  • MCMC can be slow when there are many areas; INLA reduces run time but introduces approximation error into the posterior.
  • Estimates depend on the adjacency matrix W, so a misspecified neighbor structure shifts the smoothing pattern in every area that depends on it.
  • Prior choices for the precision parameters can strongly influence the amount of smoothing when counts are sparse.
  • Posterior summaries for several random effects are harder to communicate to non-statistical audiences than a single Moran's I value.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Gives a posterior distribution for each area's risk, so credible intervals and exceedance probabilities are available alongside point estimates.
  • Borrows strength across neighbors through the CAR prior, which stabilizes estimates for areas with small counts.
  • The BYM decomposition separates a spatially structured component from an unstructured one, so the contribution of neighborhood dependence can be compared with area-specific heterogeneity.
  • INLA makes the model practical for many areal datasets without full MCMC runs, although it approximates the posterior rather than sampling it.

Applications

  • Disease mapping: smoothed relative risks for small areas where raw rates are unstable.
  • Crime analysis: area-level rate estimates with credible intervals for comparing neighborhoods.
  • Ecological risk assessment: area-level exposure or abundance estimates across administrative units.
  • Regional economics: smoothed area indicators, such as unemployment rates, where neighboring areas inform one another.

How it works

How it works

1

The spatially structured effects φ receive a Conditional Autoregressive (CAR) prior with precision τ² and adjacency matrix W. Each area's effect is centered on a weighted average of its neighbors' effects, so W determines which areas share information. A larger precision τ² means less variation among the structured effects. The intrinsic form of the CAR prior is improper, so φ is constrained to sum to zero. This centering constraint separates φ from the global intercept α and makes the model identifiable.

Formula
\phi \sim \text{CAR}(\tau^2, W)
2

The observed counts y_i are modeled as Poisson with mean E_i μ_i, where E_i is the known expected count (offset) for area i and μ_i is the relative risk. The log relative risk is log μ_i = α + φ_i + θ_i: α is a global intercept, φ_i is the spatially structured effect, and θ_i is an unstructured heterogeneity effect. The unstructured effects θ_i are independent zero-mean normal random effects, θ_i ~ N(0, 1/τ_θ²), where τ_θ² is their precision and is given a hyperprior. The choice of hyperprior should be reported with the results.

Formula
y_i \mid \mu_i \sim \text{Poisson}(E_i \mu_i),\quad \log \mu_i = \alpha + \phi_i + \theta_i
3

The joint posterior of the latent effects and hyperparameters is proportional to the likelihood multiplied by the priors. It has no closed form, so it must be approximated numerically.

Formula
p(\phi, \theta \mid y) \propto p(y \mid \phi, \theta)\, p(\phi)\, p(\theta)
4

Markov chain Monte Carlo (MCMC) draws samples from the posterior. INLA (Integrated Nested Laplace Approximation) instead gives a deterministic approximation for latent Gaussian models of this type. For MCMC output, convergence diagnostics such as R-hat and effective sample size should be checked before summaries are reported.

5

The main outputs are posterior summaries for each area, such as posterior means of relative risk, credible intervals, and exceedance probabilities. The amount of spatial structure is summarized through the posterior of the variance (or precision) parameters of the random effects. A common summary of spatial dependence in the BYM model is the proportion of random-effect variance that is spatially structured. It is computed draw by draw from the posterior samples of the two variance components, as the spatial variance (the inverse of the spatial precision) divided by the sum of the spatial and unstructured variances, and is then reported as a posterior mean with a credible interval. Values near 1 indicate that the spatially structured effect accounts for most of the random-effect variation, and values near 0 indicate that unstructured heterogeneity dominates.

Common pitfalls

  • Relying on default or vague priors without a sensitivity check. With sparse counts, the amount of spatial smoothing may be driven more by the prior than by the data.
  • Reporting MCMC summaries without checking convergence; non-converged chains give unreliable posterior means and intervals.
  • Confusing spatial autocorrelation in model residuals, which is a diagnostic, with this hierarchical model, which is a substantive model of area risk.
  • Reading exceedance probabilities as frequentist p-values. They are posterior probabilities under the assumed model and priors.
  • Using a binary contiguity matrix without checking whether distance-based or higher-order neighbor structures better reflect the process being modeled.

Frequently asked questions

How does Bayesian Spatial Autocorrelation differ from Moran's I?

Moran's I is a single descriptive statistic that tests for global spatial clustering with a p-value. Bayesian Spatial Autocorrelation is a full hierarchical model that estimates smoothed area-level effects, decomposes spatial and non-spatial variation, and yields posterior distributions rather than a single number. They answer different questions: 'Is there clustering?' versus 'What is the locally varying risk with uncertainty?'

What is the BYM model?

BYM stands for Besag-York-Mollie (1991). It specifies the log-risk in each area as the sum of a spatially structured CAR component (φ) and an independent unstructured heterogeneity component (θ). This decomposition allows the model to separate spatially patterned variation from area-specific heterogeneity that is not spatially structured.

Can I use INLA instead of MCMC?

Yes. Integrated Nested Laplace Approximation (INLA) gives deterministic approximations to posteriors for latent Gaussian models, which include CAR-based spatial models. The R-INLA package implements it. INLA approximates the posterior rather than sampling it, so when accuracy is critical, its results can be compared with MCMC output.

How do I define the neighborhood matrix W?

The most common approach is queen or rook contiguity: areas sharing a boundary (or a corner, for queen) are coded as neighbors (W_ij = 1). For point data snapped to a lattice, k-nearest-neighbor or distance-band adjacency may be more appropriate. The choice of W directly shapes the estimated spatial autocorrelation structure and should reflect the substantive process being modeled.

What software implements Bayesian Spatial Autocorrelation?

R-INLA (via the INLA package) is the most widely used tool for areal Bayesian spatial models. Alternatives include Stan (via brms or custom Stan code) for MCMC-based inference, and the CARBayes package in R for BYM and related models. Python users can use PyMC with custom CAR log-probability functions.

Related methods

Sources

  1. Besag, J., York, J., & Mollie, A. (1991). Bayesian image restoration, with two applications in spatial statistics. Annals of the Institute of Statistical Mathematics, 43(1), 1–20.

    Open DOI reference
  2. Gelfand, A. E., Diggle, P., Guttorp, P., & Fuentes, M. (Eds.). (2010). Handbook of Spatial Statistics. CRC Press.

    ISBN: 978-1420072877