Plots entropy against number of blocks left for a collapse run. If heuristic is set to value other than NULL a second plot of the score for each merger step according to the heuristic provided is also shown.

visualize_collapse_results(
  sbm,
  use_entropy_value_for_score = FALSE,
  heuristic = NULL
)

Arguments

sbm

Object of class sbm_network.

use_entropy_value_for_score

If set to TRUE then instead of the merge results entropy delta being used for the score function the entropy will be. Typically the heuristics work better on entropy delta values.

heuristic

How the best partitioning is defined. Takes either a function that takes one/two arguments: an entropy vector and an optional number of blocks vector with each element corresponding to a given location, or a string labeling algorithm. Currently only "lowest", "dev_from_rolling_mean", "delta_ratio", "trend_deviation", and "nls_residual" are supported.

Value

GGplot object comparing the fit results and each step's deviance from the rolling mean

Details

Either collapse_run, or collapse_blocks(report_all_steps = TRUE) must be run prior to calling this function. (See collapse_blocks.)

See also

Examples

set.seed(42) # Start with a random networ and run agglomerative clustering with no # intermediate MCMC steps on sbm of simulated data net <- sim_basic_block_network(n_blocks = 3, n_nodes_per_block = 35) %>% collapse_blocks(sigma = 1.5) # ============================================================================= # Visualize using no heuristic visualize_collapse_results(net)
# ============================================================================= # Visualize using deviance from rolling average heuristic visualize_collapse_results(net, heuristic = 'dev_from_rolling_mean')
# ============================================================================= # Visualize using custom heuristic # Score heuristic that fits a nonlinear model to observed values and chooses by # largest negative residual (built into package as heuristic = "nls_residual") nls_score <- function(e, k){ entropy_model <- nls(e ~ a + b * log(k), start = list(a = max(e), b = -25)) -residuals(entropy_model) } visualize_collapse_results(net, heuristic = nls_score)