Performs agglomerative merging on network, starting with each block has a
single node down to one block per node type. Arguments are level to perform
merge at (int) and number of MCMC steps to peform between each collapsing to
equilibriate block. See the agglomerative_merging.Rmd
vignette for more
complete discussion of options/behavior.
collapse_blocks( sbm, desired_num_blocks = 1, num_mcmc_sweeps = 0, sigma = 2, eps = 0.1, num_block_proposals = 5, level = 0, report_all_steps = TRUE )
sbm |
|
---|---|
desired_num_blocks | How many blocks should this given merge drop down to. If the network has more than one node type this number is multiplied by the total number of types. |
num_mcmc_sweeps | How many MCMC sweeps the model does at each agglomerative merge step. This allows the model to allow nodes to find their most natural resting place in a given collapsed state. Larger values will slow down runtime but can potentially lead for more stable results. |
sigma | Controls the rate of collapse. At each step of the collapsing
the model will try and remove |
eps | Controls randomness of move proposals. Effects both the block merging and mcmc sweeps. |
num_block_proposals | Controls how many merger proposals are drawn for each block in the model. A larger number will increase the exploration of merge potentials but may lead the model to local minimums. If the number of proposals is greater than then number of blocks then all blocks are searched exhaustively. |
level | Level of nodes who's blocks will have their block membership run through MCMC proposal-accept routine. |
report_all_steps | Should the model state be provided for every merge
step or just the final one? If collapsing is being used to infer
hierarcichal structure in data or inspection is desired this should be set
to |
An S3 object of class sbm_network
. For details see
new_sbm_network
section "Class structure."
Other modeling:
choose_best_collapse_state()
,
collapse_run()
,
get_block_edge_counts()
,
get_entropy()
,
get_num_blocks()
,
get_state()
,
mcmc_sweep()
set.seed(42) # Start with a random network of two blocks with 25 nodes each net <- sim_basic_block_network(n_blocks = 3, n_nodes_per_block = 25) %>% collapse_blocks(sigma = 1.2) # We can look directly at the collapse results net %>% get_collapse_results()#> # A tibble: 22 x 4 #> entropy entropy_delta num_blocks state #> <dbl> <dbl> <int> <list> #> 1 1453. 156. 63 <df[,4] [201 × 4]> #> 2 1581. 129. 53 <df[,4] [181 × 4]> #> 3 1683. 102. 45 <df[,4] [165 × 4]> #> 4 1772. 88.9 38 <df[,4] [151 × 4]> #> 5 1842. 70.1 32 <df[,4] [139 × 4]> #> 6 1894. 51.7 27 <df[,4] [129 × 4]> #> 7 1929. 35.0 23 <df[,4] [121 × 4]> #> 8 1960. 30.5 20 <df[,4] [115 × 4]> #> 9 1986. 26.7 17 <df[,4] [109 × 4]> #> 10 2005. 18.3 15 <df[,4] [105 × 4]> #> # … with 12 more rows# We can choose best result with default heuristic net <- choose_best_collapse_state(net, verbose = TRUE)#> Choosing collapse with 3 blocks and an entropy of 2122.002.# Setting sigma to a higher value means faster collapsing at the cost of less accuracy net %>% collapse_blocks(sigma = 2) %>% visualize_collapse_results()