Background
Classical spatial models for discrete data typically use a Markov random field (MRF), which specifies a joint distribution over an undirected graph. However, the MRF likelihood involves an intractable normalizing constant (the partition function), making exact Bayesian inference computationally burdensome.
The Mixture of Directed Graphical Models (MDGM) is an alternative that takes the same undirected graph as input but defines a mixture over compatible directed acyclic graphs (DAGs). Each DAG admits a tractable factorization, so the MDGM avoids the partition function entirely. The joint distribution marginalizes over the DAG space: .
For full details, see Carter and Calder (2024).
The MDGM prior
Let be an undirected graph (the “natural undirected graph” or NUG) encoding potential neighbor relationships. The MDGM places a prior over DAGs that are compatible with : every directed edge in corresponds to an undirected edge in .
Three DAG constructions are supported:
Spanning trees
A spanning tree of is a connected, acyclic subgraph containing all vertices. Edges are directed from child to parent. The posterior sampling uses Wilson’s algorithm with data-dependent edge weights:
where is the spatial dependence parameter and is the color assignment. This provides a direct (non-MH) posterior sample of the spanning tree.
Acyclic orientations
An acyclic orientation assigns a direction to every edge in such that no directed cycle exists. Equivalently, this is defined by a vertex permutation : edge is directed as if . The MCMC proposes new permutations and accepts via a Metropolis-Hastings step based on the exact DAG log-likelihood ratio.
Spatial field model
Given a DAG , each vertex has a set of parents . The conditional distribution of the color given its parents is:
$$p(z_i = k \mid z_{\text{pa}(i)}, \psi) \propto \exp\Bigl(\psi \sum_{j \in \text{pa}(i)} \mathbf{1}[z_j = k] + \alpha_k\Bigr)$$
where are marginal log-probabilities (currently fixed at 0 for a uniform marginal).
Standalone vs. hierarchical models
Standalone model
In the standalone model, the spatial field is observed directly. The MCMC updates only the DAG structure and the dependence parameter . This is useful when the data are categorical labels on a spatial domain.
Hierarchical model
In the hierarchical model, is a latent field and observations are generated through an emission distribution:
Currently supported emission families:
- Bernoulli: , with identifiability constraint enforced via truncated Beta posterior sampling.
- Gaussian: , with identifiability constraint . Independent Normal and Inverse-Gamma conjugate updates for and .
- Poisson: , with identifiability constraint . Conjugate truncated Gamma updates.
The MCMC additionally updates (Gibbs scan over vertices) and the emission parameters (conjugate updates). See the Emission Models vignette for worked examples.
Prior specification
Dependence parameter
The spatial dependence parameter has a half-Cauchy prior:
Updates use a Metropolis-Hastings random walk with a normal proposal.
Emission parameters
-
Bernoulli: Each
has a
prior.
emission_prior_params = c(a, b). -
Gaussian:
and
,
independently.
emission_prior_params = c(mu_0, sigma2_0, alpha_0, beta_0). -
Poisson: Each
has a
prior (rate parameterization).
emission_prior_params = c(alpha_0, beta_0).
All conjugate posteriors use truncated sampling to enforce parameter ordering for identifiability.
MCMC algorithm
Each iteration of the MCMC sampler performs:
- Update DAG — Sample a new spanning tree (direct posterior sample via Wilson’s) or propose a new acyclic orientation/root (MH step).
- Update (hierarchical only) — Gibbs scan over vertices in random order. The full conditional combines the spatial prior with the emission likelihood.
- Update — Metropolis-Hastings with normal random walk proposal.
- Update (hierarchical only) — Conjugate posterior sampling with identifiability constraints.