R/collapse_run.R
collapse_run.Rd
Run Agglomerative Merging to target a range of block numbers
collapse_run( sbm, num_final_blocks = 1:10, num_mcmc_sweeps = 10, sigma = 2, eps = 0.1, num_block_proposals = 5, parallel = FALSE )
sbm |
|
---|---|
num_final_blocks | Array of integers corresponding to number of blocks to check in run. |
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. |
parallel | Run in parallel using |
An S3 object of class sbm_network
. For details see
new_sbm_network
section "Class structure."
Other modeling:
choose_best_collapse_state()
,
collapse_blocks()
,
entropy()
,
interblock_edge_counts()
,
mcmc_sweep()
,
n_blocks()
,
state()
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_run(num_final_blocks = 1:5, sigma = 1.5) # Collapse runs can be done in parallel if (FALSE) { net <- sim_basic_block_network(n_blocks = 3, n_nodes_per_block = 25) %>% collapse_run(num_final_blocks = 1:5, sigma = 1.5, parallel = TRUE) } # We can look directly at the collapse results net %>% get_collapse_results()#> # A tibble: 5 x 3 #> entropy n_blocks state #> <dbl> <int> <list> #> 1 2227. 1 <df[,4] [75 × 4]> #> 2 2143. 2 <df[,4] [75 × 4]> #> 3 2033. 3 <df[,4] [75 × 4]> #> 4 2035. 4 <df[,4] [75 × 4]> #> 5 2029. 5 <df[,4] [75 × 4]>#> Warning: Can't use entropy delta for collapse score because collapse results doesn't report entropy delta for results from collapse_run(). Using entropy instead.# We can choose best result with default heuristic net <- choose_best_collapse_state(net, verbose = TRUE, use_entropy = TRUE)#> Choosing collapse with 3 blocks and an entropy of 2032.8128.