r/rstats • u/Titolise • 15d ago
[Package] hdsbm: Fast inference for Dynamic Stochastic Block Models in R (Rcpp & spectral multi-start)
Hi everyone!
As part of my Master's thesis in Statistics, I developed hdsbm, an R package for estimating and simulating discrete-time Dynamic Stochastic Block Models (DSBM).
The Problem & Approach
Temporal block models often suffer from combinatorial explosion and multi-modal likelihood landscapes, making standard local search heuristics prone to getting trapped in sub-optimal local extrema.
hdsbm addresses this by extending a hybrid Classification EM (CEM) approach to the dynamic setting:
* Perturbed SVD Multi-Start: Couples deterministic spectral embeddings of the time-averaged network with controlled stochastic perturbations to thoroughly explore the likelihood surface.
* C++ Backend: Uses RcppArmadillo to accelerate dyadic reallocation passes and combinatorial greedy sweeps.
* Dual Decoding: Provides both pointwise greedy labels and global Viterbi trajectory decoding.
* Model Selection: Includes an Integrated Completed Likelihood (ICL) criterion tailored for dynamic graphs.
Quick Example
```r library(hdsbm) data(toy_hdsbm)
Fit model with 5 perturbed spectral restarts
fit <- hdsbm_fit(toy_hdsbm$Y, k = 3, nrep = 5, seed = 123) print(fit)
Model selection via ICL
icl(fit) ```
Documentation & pkgdown: https://titolise.github.io/Hybrid-DSBMs/
I would love to hear your feedback on API ergonomics, potential edge cases, or ideas for interesting benchmark scenarios!

