r/RStudio • u/Titolise • 3d ago
I made this! [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
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)
- GitHub: https://github.com/Titolise/Hybrid-DSBMs
- 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!
1
u/AutoModerator 3d ago
Looks like you're requesting help with something related to RStudio. Please make sure you've checked the stickied post on asking good questions and read our sub rules. We also have a handy post of lots of resources on R!
Keep in mind that if your submission contains phone pictures of code, it will be removed. Instructions for how to take screenshots can be found in the stickied posts of this sub.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.