Spatial Gibbs Sampling

Statistics
Introduced by
Stuart Geman and Donald Geman
Year
1984
Type
MCMC sampling algorithm for spatial models
Family
Bayesian / computational

What does it do?

Spatial Gibbs sampling applies the Gibbs sampler, a coordinate-wise Markov chain Monte Carlo algorithm, to models in which observations are indexed by location and nearby sites are statistically dependent.

The spatial neighbourhood structure implies conditional independence, so each site can be updated in turn given its neighbours and local data, which keeps every draw low-dimensional. The approach is used for Markov random fields, Gaussian Markov random fields and hierarchical geostatistical models with discretised spatial fields.

The intuition behind the method

Imagine a map divided into grid cells or irregular regions. Each cell's value depends mainly on its immediate neighbours, not on distant cells. Spatial Gibbs sampling exploits this local dependence: it cycles through the locations and draws a new value for each one, conditioned only on the current values of its neighbours and the local data. After many sweeps the chain of draws approximates the joint posterior over the whole map, so uncertainty at each location can be summarised without computing the joint density directly.

History

Gibbs-type sampling for spatial models traces to Geman and Geman's 1984 paper, which modelled images as Markov random fields with Gibbs distributions and used annealing-type relaxation to find maximum a posteriori restorations of degraded images. Conditionally autoregressive (CAR) priors, widely used for lattice and areal data and particularly in disease mapping, fit naturally into this framework. Rue and Held (2005) give a general treatment of Gaussian Markov random fields. Approximate methods such as INLA offer an alternative for latent Gaussian models where full MCMC is slow.

When to use it

Use spatial Gibbs sampling when the outcome is indexed by geographic location, nearby observations are expected to be correlated, and you want a fully Bayesian posterior over spatially varying parameters. It suits lattice or areal data such as disease maps, remote-sensing images and image restoration, and geostatistical models where a discretised approximation of the field is acceptable. Prefer it to a generic random-walk Metropolis sampler when the full conditionals are available in a form that can be sampled directly, since each site update is then a direct draw. Do not use it when spatial dependence is negligible and an independence model suffices, or when the lattice is so large that repeated Gibbs sweeps are impractical and an approximate method such as INLA is more appropriate.

Limitations and considerations

  • Convergence can be slow when spatial dependence is very strong (near the critical regime of the MRF), because neighbouring sites move together and the chain mixes poorly.
  • Requires full conditionals that are closed-form or efficiently sampleable; non-conjugate likelihoods often need auxiliary-variable methods or embedded Metropolis steps.
  • Computational cost scales with the number of spatial locations N and the number of MCMC iterations, which makes very large grids expensive without specialised blocking.
  • Storing the full spatial field at each retained iteration can be memory-intensive for high-resolution maps.
  • Diagnostics for spatial MCMC are more involved than for independent parameters; a scalar R-hat computed on a few summaries may not reveal spatial non-stationarity.

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

Strengths

  • Exploits the Markov conditional-independence structure of spatial priors to reduce sampling to a sequence of low-dimensional draws.
  • Produces a full joint posterior over the spatial field, so uncertainty can be read off at every location from the same set of samples.
  • Accommodates hierarchical spatial models with structured random effects, unstructured noise and covariates within one sampler.
  • Blocked or coloured-graph updates on regular lattices allow parallel sampling of conditionally independent sites, which can reduce wall-clock time.
  • The update rule at each site is a single conditional draw, so the algorithm is straightforward to implement and to check against the model specification.

Applications

  • Disease mapping: estimating smoothed relative-risk surfaces for small-area health outcomes using CAR-type spatial priors.
  • Remote sensing and satellite image analysis: restoring or classifying images modelled as MRFs on pixel lattices.
  • Environmental monitoring: interpolating and mapping spatially correlated pollutant concentrations with uncertainty bands.
  • Ecology: species distribution modelling with spatially structured random effects to account for unobserved habitat variation.
  • Real-estate analytics: estimating spatially varying price gradients while sharing information across neighbouring census tracts.
  • Criminology and social science: small-area estimation of crime rates with hierarchical spatial random effects.

How it works

How it works

1

Specify a spatial prior, typically a Markov random field (MRF) or Gaussian Markov random field (GMRF), that encodes how strongly adjacent locations are expected to resemble each other. The prior is written through clique potentials over the neighbourhood graph, so large differences between neighbouring values are penalised, as in the energy expression above. The Gibbs–MRF equivalence that underlies this construction requires the joint distribution to be strictly positive on its support (the positivity condition of the Hammersley–Clifford theorem). Hard constraints or deterministic relationships between neighbouring sites violate this condition and call for a reparameterisation or a different update scheme.

Formula
p(\mathbf{x}) \propto \exp\!\left(-\sum_{(i,j)\in\mathcal{E}} V_{ij}(x_i, x_j)\right)
2

The Markov property of the spatial prior means that each site's full conditional distribution depends only on its immediate neighbours (its Markov blanket) and its local likelihood term. Written in terms of the energy, the full conditional is p(x_i | x_−i, y) ∝ p(y_i | x_i) · exp(−Σ_{j∼i} V_ij(x_i, x_j)), where the sum runs only over the neighbours j of site i. This replaces a high-dimensional joint posterior with a set of low-dimensional conditionals. Each conditional can be sampled directly when it has a known form, or with a simple accept-reject step when it does not.

Formula
p(x_i \mid \mathbf{x}_{-i},\,\mathbf{y}) \propto p(y_i \mid x_i)\,p(x_i \mid x_{\partial i})
3

A Gibbs sweep visits every site, in a fixed or random order, and draws a new value from that site's full conditional; one complete sweep is one MCMC iteration. Fixed-scan and random-scan orderings are both valid. On regular lattices, blocked updates that sample groups of mutually conditionally independent sites together can reduce the run time per sweep.

4

Run multiple chains from dispersed starting values and monitor convergence with R-hat and effective sample size diagnostics. For spatial models with strong local dependence, consecutive sweeps can be highly autocorrelated, so a long run and thinning may be needed. Trace plots and variogram diagnostics on the residuals help check that the chain is stationary and that spatial structure is adequately captured.

5

After discarding a burn-in period, posterior summaries are computed from the retained samples. Posterior means give smoothed spatial maps, credible intervals quantify location-specific uncertainty, and spatial random effects can be decomposed into structured and unstructured components.

Formula
\hat{x}_i = \frac{1}{T}\sum_{t=1}^{T} x_i^{(t)}

Common pitfalls

  • Failing to check convergence with multiple chains and spatial diagnostics, and then reporting summaries from a chain that has not stabilised.
  • Choosing a neighbourhood order (first-order or second-order adjacency) without justification, since this choice controls the smoothness of the inferred field.
  • Ignoring the identifiability constraint when the model includes both a spatial random effect and an intercept; for intrinsic priors the intercept and the spatial effect are confounded and a constraint is needed.
  • Placing a flat or improper prior on the spatial precision parameter, which can leave the smoothing strength weakly identified and may not yield a proper posterior for intrinsic models; a proper prior, such as a gamma prior on the precision, is a common alternative.
  • Treating thinned samples as independent when autocorrelation remains high, which overstates the effective sample size.

Frequently asked questions

How does spatial Gibbs sampling differ from ordinary Gibbs sampling?

Ordinary Gibbs sampling cycles through all model parameters, treating them symmetrically. Spatial Gibbs sampling targets models in which parameters or latent variables correspond to geographic locations connected in a neighbourhood graph. The spatial Markov property reduces each full conditional to a dependence on immediate neighbours, so the conditionals remain low-dimensional however many sites there are.

What is a CAR prior and why is it used?

A conditionally autoregressive (CAR) prior specifies each site's conditional distribution as a function of its neighbours' values, which induces spatial smoothness. The intrinsic CAR (ICAR) form pulls each site's estimate toward the values of its neighbours, so smoothing is local to the neighbourhood graph rather than toward a global mean. It is widely used in disease mapping because it is interpretable and fits naturally into a Gibbs sampler, and in data-sparse areas it borrows strength from adjacent sites.

When should I prefer INLA over spatial Gibbs sampling?

INLA (Integrated Nested Laplace Approximation) gives fast approximate posteriors for latent Gaussian models, including models with non-Gaussian likelihoods such as Poisson or binomial, without running MCMC. Prefer INLA when the model fits the latent-Gaussian framework, the lattice is large, and speed matters. Prefer spatial Gibbs sampling when you need exact posterior samples in the MCMC sense, when the latent structure falls outside what the approximation handles well, or when you need to propagate the full posterior samples through further non-linear post-processing.

How do I diagnose convergence for a spatial Gibbs chain?

Use standard MCMC diagnostics, namely R-hat across multiple chains, effective sample size and trace plots, applied to scalar summaries such as the spatial precision parameter and selected site-level values. Also inspect empirical variograms of residuals from retained samples to check that spatial autocorrelation is adequately captured and is not drifting across iterations.

Can spatial Gibbs sampling handle non-Gaussian likelihoods, such as Poisson counts?

Yes. For Poisson or binomial likelihoods the spatial random-effect full conditional is no longer conjugate, so the Gibbs step at each site is replaced by a Metropolis-Hastings step or an auxiliary-variable scheme, for example Polya-Gamma data augmentation for binomial data. The outer structure of sweeping through the neighbourhood graph stays the same; only the individual site updates change.

Related methods

Sources

  1. Geman, S. & Geman, D. (1984). Stochastic relaxation, Gibbs distributions, and the Bayesian restoration of images. IEEE Transactions on Pattern Analysis and Machine Intelligence, 6(6), 721–741.

    Open DOI reference
  2. Rue, H. & Held, L. (2005). Gaussian Markov Random Fields: Theory and Applications. Chapman & Hall/CRC.

    ISBN: 978-1584884323