DIGITAL.CSIC. Repositorio Institucional del CSIC
Publicación
Artículo científico (JournalArticle)
sabinaHSBM: An R package for link prediction and network reconstruction using hierarchical stochastic block models
Network analysis is a powerful framework for investigating complex systems across disciplines, including ecology. However, ecological network data are often incomplete or error-prone due to sampling limitations, detection failures and taxonomic uncertainty—leading to missing (false negative) and spurious (false positive) links that obscure structure and hinder inference. The hierarchical stochastic block model (HSBM), particularly in its degree-corrected form, is among the most effective tools for reconstructing networks under such uncertainty. Despite its robustness, the primary implementation of HSBM in the Python-based graph-tool library has remained largely inaccessible to ecologists., Here, we introduce sabinaHSBM, the first R package that makes degree-corrected HSBM broadly available through a user-friendly, flexible workflow. By bridging a gap between advanced network modelling and widely used ecological analysis tools, sabinaHSBM facilitates network reconstruction and link prediction from binary data. The workflow involves three main steps: (1) preparing input data, (2) estimating posterior link probabilities and (3) reconstructing the network. The package supports detection of undocumented and spurious links, exploration of hierarchical structure and propagation of uncertainty throughout. Key features include cross-validation, flexible thresholding, probabilistic evaluation metrics and two link prediction methods: estimating all link probabilities or identifying undocumented ones., We illustrate the package's functionality through a case study using a published global dataset of carnivore–parasite associations, showing that inferred groupings are phylogenetically clustered. To assess predictive accuracy, we examined the top 10 highest probability links identified by the model and found published evidence for eight, despite their absence from the original dataset. This highlights the model's ability to recover biologically meaningful but unrecorded interactions., By providing the first accessible R workflow for HSBM-based network reconstruction, sabinaHSBM enables researchers to quantify uncertainty and recover overlooked interactions in ecological networks., This study was supported by project Grant (NextDive; PID2021-124187NB-I00) funded by MCIN/AEI/10.13039/501100011033 and by ‘ERDF A way of making Europe’. H. L. was supported by the FPI program of the Spanish Ministry for Science and Innovation (grant CGL2017-86926-P). I.M.-C. acknowledges funding from the Spanish Ministry for Science and Innovation (grant number PID2023-152329OB-I00 to I.M.-C.)., Peer reviewed
Proyecto:
AEI / Plan Estatal de Investigación Científica y Técnica y de Innovación 2021-2023 PID2021-124187NB-I00
,
AEI / Plan Estatal de Investigación Científica y Técnica y de Innovación 2017-2020 CGL2017-86926-P
,
AEI / Plan Estatal de Investigación Científica y Técnica y de Innovación 2021-2023 PID2023-152329OB-I00