Used for testing properties of algorithms. Will create an association network that is constructed where some nodes are more "sticky" than others. Or they are in general more associated than others.

simulate_sticky_association_network(
  n_variables = 50,
  n_clusters = 4,
  cluster_coherence = 2,
  stickiness_dist = function(n) {     stats::rbeta(n, shape1 = 1, shape2 = 4) },
  association_dist = function(n) {     stats::rbeta(n, shape1 = 0.5, shape2 = 10) }
)

Arguments

n_variables

How many variables will be simulated

n_clusters

Controls how many clusters are randomly assigned to nodes

cluster_coherence

Scalar that multiplies random association value for nodes in the same clusters. E.g. A value of 2 means variables in same cluster have on average twice the association strength. Most likely above 1.

stickiness_dist

Function that takes a single input: n that will then generate n values from a distribution used to assign stickiness level for each variable. These values will be scaled to an average of 1 so stickiness doesn't change association distribution too much.

association_dist

Function of same format as stickiness_dist that instead is used to generate raw associations between pairs of nodes. The values will then be scaled by cluster_coherence and each variable's stickiness.

Value

List with variables with info about each variable (id, stickiness scalar, and cluster id) and associations which contains the simulated associations in the format that works for all the functions that take association_pairs as an input.

Examples

# Simulate an association network with flat stickiness profile simulate_sticky_association_network( n_variables = 10, n_clusters = 3, cluster_coherence = 2, stickiness_dist = function(n) {runif(n)}, association_dist = function(n) {rbeta(n, shape1 = 1, shape2 = 10)} )
#> $variables #> # A tibble: 10 x 3 #> id stickiness cluster #> <int> <dbl> <int> #> 1 1 0.0913 1 #> 2 2 0.854 3 #> 3 3 1.07 3 #> 4 4 0.521 1 #> 5 5 1.08 2 #> 6 6 0.170 3 #> 7 7 1.04 3 #> 8 8 2.60 3 #> 9 9 0.773 2 #> 10 10 1.81 1 #> #> $associations
#> Error: Input must be a vector, not NULL.