Stochastic Blockmodels

A collection of tools and functions to adjust a variety of stochastic blockmodels (SBM). Supports at the moment Simple, Bipartite, 'Multipartite' and Multiplex SBM (undirected or directed with Bernoulli, Poisson or Gaussian emission laws on the edges). For Simple and Bipartite SBM, covariates can be given on the edges, or on the nodes to drive the block memberships, and the network may contain missing values. See Léger (2016) , 'Barbillon et al.' (2020) and 'Bar-Hen et al.' (2020) .


sbm: Stochastic Blockmodels

CRANstatus R-CMD-check pkgdown Codecov testcoverage Lifecycle:stable

sbm gathers in a single framework the tools to simulate, estimate and represent a variety of stochastic block models (SBM), a family of models that cluster the nodes of a network into blocks sharing the same connectivity patterns.

Supported models

Network Function Estimation engine
Simple (one set of nodes, directed or not) estimateSimpleSBM() blockmodels
Bipartite (two sets of nodes) estimateBipartiteSBM() blockmodels
Multipartite (several sets of nodes and networks) estimateMultipartiteSBM() GREMLINS
Multiplex (several networks on the same nodes) estimateMultiplexSBM() GREMLINS (independent layers), blockmodels (dependent layers)
  • Emission distributions on the edges: Bernoulli (binary networks), Poisson (counts) and Gaussian (weights).
  • Covariates, for simple and bipartite SBM: on the edges, acting on the connectivity, or on the nodes, driving the block memberships.
  • Missing values (NA) in the networks: the missing dyads are ignored in the inference (see the help pages for the details of each model).
  • Model selection of the number of blocks with the Integrated Classification Likelihood (ICL).
  • Graphics with ggplot2: reordered matrices, expected networks, graphons, mesoscopic views and alluvial plots.
  • Simulation of networks with sampleSimpleSBM(), sampleBipartiteSBM(), sampleMultipartiteSBM() and sampleMultiplexSBM().

Installation

The stable version is available on CRAN:

install.packages("sbm")

The development version can be installed from GitHub:

# install.packages("pak")
pak::pak("GrossSBM/sbm")

Example

The data set fungusTreeNetwork records the interactions between 154 fungal species and 51 tree species. A bipartite SBM groups the fungi and the trees into blocks sharing the same interaction patterns, the number of blocks being chosen with the ICL.

library(sbm)
data("fungusTreeNetwork")
fungusTree <- fungusTreeNetwork$fungus_tree

fit <- estimateBipartiteSBM(
  fungusTree, model = "bernoulli", dimLabels = c(row = "fungus", col = "tree"),
  estimOptions = list(verbosity = 0, plot = FALSE, nbCores = 1)
)
fit$nbBlocks
#> fungus   tree 
#>      4      4
library(patchwork)
plot(fit, type = "data") + plot(fit, type = "meso")
Left: incidence matrix of the fungus-tree network, reordered by blocks. Right: mesoscopic view, the blocks of fungi and trees connected according to their probability of interaction.

The vignettes go further: model principles, case studies on simple, bipartite, multipartite and multiplex networks, and covariates on the nodes.

Related packages

  • blockmodels: estimation of simple and bipartite SBM (and of dependent multiplex SBM), used by sbm.
  • GREMLINS: estimation of multipartite SBM, used by sbm.
  • missSBM: SBM for networks with missing data, under various sampling designs (missing at random or not).
  • shinySbm: a Shiny application to fit SBM with sbm.

References

  • Léger, J.-B. (2016). Blockmodels: A R-package for estimating in Latent Block Model and Stochastic Block Model, with various probability functions, with or without covariates. arXiv:1602.07587.
  • Barbillon, P., Donnet, S., Lazega, E. and Bar-Hen, A. (2017). Stochastic block models for multiplex networks: an application to a multilevel network of researchers. Journal of the Royal Statistical Society: Series A, 180(1), 295–314. doi:10.1111/rssa.12193.
  • Bar-Hen, A., Barbillon, P. and Donnet, S. (2022). Block models for generalized multipartite networks: Applications in ecology and ethnobiology. Statistical Modelling, 22(4), 273–296. doi:10.1177/1471082X20963254.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("sbm")

1.0.0 by Julien Chiquet, 5 days ago


https://grosssbm.github.io/sbm/


Report a bug at https://github.com/GrossSBM/sbm/issues


Browse source code at https://github.com/cran/sbm


Authors: Julien Chiquet [aut, cre] (ORCID: , Sophie Donnet [aut] , Pierre Barbillon [aut] , Louis Lacoste [aut] , Jean-Benoist Leger [ctb] , Julie Aubert [ctb] , großBM team [ctb]


Documentation:   PDF Manual  


GPL (>= 3) license


Imports alluvial, magrittr, dplyr, purrr, blockmodels, R6, Rcpp, igraph, ggplot2, GREMLINS, rlang, reshape2, prodlim, grDevices

Suggests testthat, spelling, knitr, rmarkdown, aricode, pROC, covr, quarto, patchwork

Linking to Rcpp, RcppArmadillo

System requirements: Quarto command line tool (<https://github.com/quarto-dev/quarto-cli>)


Imported by missSBM, normalblockr.

Depended on by shinySbm.


See at CRAN