sbm: Stochastic Blockmodels

CRAN status R-CMD-check pkgdown Codecov test coverage 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)

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.

References