Simulates nodes and edges from a network where edge edges are derived
from the Stochastic Block Model. A dataframe describing the different blocks
present and the number of nodes within them, a dataframe that provides the
propensity
of edge between two edges, and a distribution function
who's main parameter the propensity
value defines are needed.
sim_sbm_network( block_info, edge_propensities, edge_dist = stats::rpois, allow_self_edges = FALSE, keep_edge_counts = TRUE, setup_model = FALSE, random_seed = NULL )
block_info | A dataframe/tibble with two columns: |
---|---|
edge_propensities | A dataframe with 3 columns: |
edge_dist | A distribution function that has two inputs: the first is
number of samples to draw and the second the |
allow_self_edges | Should nodes be allowed to have edges to themselves? |
keep_edge_counts | Should the edge counts stay on returned
edges? If edges distribution is a binary yes or no then you will likely
want to set this to |
setup_model | Should an SBM model object be added? Set to |
random_seed | Integer seed to be passed to model's internal random sampling engine. Note that if the model is restored from a saved state this seed will be initialized again to the start value which will harm reproducability. |
An S3 object of class sbm_network
. For details see
new_sbm_network
section "Class structure."
Other simulations:
sim_basic_block_network()
,
sim_random_network()
block_info <- dplyr::tribble( ~block, ~n_nodes, "a", 10, "b", 12, "c", 15 ) edge_propensities <- dplyr::tribble( ~block_1, ~block_2, ~propensity, "a", "a", 0.7, "a", "b", 0.2, "a", "c", 0.1, "b", "b", 0.9, "b", "c", 0.4, "c", "c", 0.4, ) sim_sbm_network(block_info, edge_propensities, edge_dist = purrr::rbernoulli)#> SBM Network with 37 nodes of a single type and 234 edges. #> #> Nodes: # A tibble: 6 x 3 #> id block type #> <chr> <chr> <chr> #> 1 a_1 a node #> 2 a_2 a node #> 3 a_3 a node #> 4 a_4 a node #> 5 a_5 a node #> 6 a_6 a node #> ... #> #> Edges: # A tibble: 6 x 3 #> from to edges #> <chr> <chr> <dbl> #> 1 a_1 a_4 1 #> 2 a_1 a_5 1 #> 3 a_1 a_6 1 #> 4 a_1 a_7 1 #> 5 a_1 b_3 1 #> 6 a_1 b_6 1 #> ... #>