Stochastic Block Model Prior
The MFM-SBM (mixture of finite mixtures – stochastic block model) edge prior assigns variables to latent clusters and uses cluster-structured inclusion probabilities. The implementation is a translation of the R code accompanying Geng et al. (2019), adapted for the bgms sampler architecture. For the statistical background and usage guidance, see Edge Clustering. Source: src/priors/sbm_edge_prior.h and sbm_edge_prior.cpp.
MFM-SBM formulation
The prior has three levels:
Cluster count — The number of clusters \(K\) follows a Poisson(\(\lambda\)) prior, with a mixture-of-finite-mixtures (MFM) correction that accounts for the combinatorial allocation structure.
Cluster assignments — Each variable \(i\) is assigned to cluster \(z_i \in \{1, \ldots, K\}\) with a symmetric Dirichlet prior (concentration \(\alpha_D\)) on the cluster proportions.
Block inclusion probabilities — The inclusion probability for edge \((i, j)\) depends on whether variables \(i\) and \(j\) are in the same cluster:
\[ \pi_{ij} = \begin{cases} \pi_{\text{within}} & \text{if } z_i = z_j \\ \pi_{\text{between}} & \text{if } z_i \neq z_j \end{cases} \]
Within-block and between-block probabilities are drawn from Beta distributions with separate hyperparameters.
Gibbs updates
The update() method in StochasticBlockEdgePrior runs three sequential Gibbs steps:
1. Cluster allocations
block_allocations_mfm_sbm() updates each variable’s cluster assignment \(z_i\) by collapsed Gibbs sampling. For each variable \(i\):
- Remove variable \(i\) from its current cluster
- For each possible cluster \(k\) (including a new cluster), compute the conditional probability based on:
- The MFM allocation prior (CRP-like with log-partition coefficients \(\log V_n\))
- The likelihood of the observed edge indicators between variable \(i\) and all other variables, given the block probabilities
- Sample \(z_i\) from the resulting categorical distribution
Empty clusters are removed, and the cluster labels are relabeled to be contiguous.
2. Block probabilities
block_probs_mfm_sbm() draws new within-block and between-block inclusion probabilities from their Beta full conditionals:
\[ \pi_{kl} \sim \text{Beta}\bigl(\alpha_{kl} + e_{kl},\; \beta_{kl} + m_{kl} - e_{kl}\bigr) \]
where \(e_{kl}\) is the number of included edges between clusters \(k\) and \(l\), and \(m_{kl}\) is the total number of possible edges. The hyperparameters \(\alpha_{kl}\) and \(\beta_{kl}\) differ for within-block (\(k = l\)) and between-block (\(k \neq l\)) pairs.
3. Inclusion probability matrix
The updated block probabilities are broadcast to the full \(p \times p\) inclusion probability matrix based on the current cluster assignments.
Log partition coefficients
compute_Vn_mfm_sbm() precomputes the log-partition function \(\log V_n(t)\) for \(t = 1, \ldots, t_{\max}\). These coefficients encode the MFM prior on the number of occupied clusters and appear in the allocation Gibbs step. They are computed once at initialization.
The computation involves:
- Poisson probabilities for the total number of components
- Rising factorials (Pochhammer symbols) for the Dirichlet-multinomial allocation counts
- Log-sum-exp accumulation for numerical stability
Hyperparameters
The six SBM hyperparameters are set via bgm():
| Parameter | R argument | Default | Role |
|---|---|---|---|
| \(\alpha_w\) | beta_bernoulli_alpha |
1 | Beta shape for within-block inclusion |
| \(\beta_w\) | beta_bernoulli_beta |
1 | Beta shape for within-block inclusion |
| \(\alpha_b\) | beta_bernoulli_alpha_between |
1 | Beta shape for between-block inclusion |
| \(\beta_b\) | beta_bernoulli_beta_between |
1 | Beta shape for between-block inclusion |
| \(\alpha_D\) | dirichlet_alpha |
1 | Dirichlet concentration for cluster proportions |
| \(\lambda\) | lambda |
1 | Poisson rate for number of clusters |
All six hyperparameters are required when edge_prior = "Stochastic-Block" is selected. Validation enforces that all values are positive and finite.
Output
The cluster allocations at each post-warmup iteration are stored in ChainResult::allocation_samples and accessible via extract_sbm() in R, which returns:
posterior_num_blocks— posterior distribution over the number of clustersposterior_mean_allocations— posterior mean cluster assignmentsposterior_mode_allocations— posterior mode cluster assignmentsposterior_mean_coclustering_matrix— proportion of iterations where each pair of variables was in the same cluster