sbm {fastRG} | R Documentation |
Create an undirected stochastic blockmodel object
Description
To specify a stochastic blockmodel, you must specify
the number of nodes (via n
), the mixing matrix (via k
or B
),
and the relative block probabilites (optional, via pi
).
We provide defaults for most of these options to enable
rapid exploration, or you can invest the effort
for more control over the model parameters. We strongly recommend
setting the expected_degree
or expected_density
argument
to avoid large memory allocations associated with
sampling large, dense graphs.
Usage
sbm(
n,
k = NULL,
B = NULL,
...,
pi = rep(1/k, k),
sort_nodes = TRUE,
poisson_edges = TRUE,
allow_self_loops = TRUE
)
Arguments
n |
The number of nodes in the network. Must be a positive integer. This argument is required. |
k |
(mixing matrix) The number of blocks in the blockmodel.
Use when you don't want to specify the mixing-matrix by hand.
When |
B |
(mixing matrix) A |
... |
Arguments passed on to
|
pi |
(relative block probabilities) Relative block
probabilities. Must be positive, but do not need to sum
to one, as they will be normalized internally.
Must match the dimensions of |
sort_nodes |
Logical indicating whether or not to sort the nodes
so that they are grouped by block and by |
poisson_edges |
Logical indicating whether or not
multiple edges are allowed to form between a pair of
nodes. Defaults to |
allow_self_loops |
Logical indicating whether or not
nodes should be allowed to form edges with themselves.
Defaults to |
Details
A stochastic block is equivalent to a degree-corrected stochastic blockmodel where the degree heterogeneity parameters have all been set equal to 1.
Value
An undirected_sbm
S3 object, which is a subclass of the
dcsbm()
object.
See Also
Other stochastic block models:
dcsbm()
,
directed_dcsbm()
,
mmsbm()
,
overlapping_sbm()
,
planted_partition()
Other undirected graphs:
chung_lu()
,
dcsbm()
,
erdos_renyi()
,
mmsbm()
,
overlapping_sbm()
,
planted_partition()
Examples
set.seed(27)
lazy_sbm <- sbm(n = 1000, k = 5, expected_density = 0.01)
lazy_sbm
# by default we get a multigraph (i.e. multiple edges are
# allowed between the same two nodes). using bernoulli edges
# will with an adjacency matrix with only zeroes and ones
bernoulli_sbm <- sbm(
n = 5000,
k = 300,
poisson_edges = FALSE,
expected_degree = 8
)
bernoulli_sbm
edgelist <- sample_edgelist(bernoulli_sbm)
edgelist
A <- sample_sparse(bernoulli_sbm)
# only zeroes and ones!
sign(A)