Simulate a bipartite network
Arguments
- actors
Number or labels of primary-mode nodes.
- events
Number or labels of secondary-mode nodes.
- edges
Optional exact number of cross-mode edges.
- probability
Cross-mode edge probability when
edgesisNULL.- weight
Edge-weight distribution.
- weight_mean, weight_sd, weight_range
Weight parameters.
- seed
Optional seed.
- batch
Optional single positive whole number. When given, the simulator runs
batchtimes and returns a plainlistofbatchresults, each exactly what the same call withoutbatchreturns. With aseed, every dataset gets its own seed drawn fromseed, so the whole batch is reproducible; without one the datasets are consecutive draws from the session's random-number stream. The defaultNULLreturns a single result.
Value
A tidy cross-mode edge-list simulab_sim base data.frame with one
row per actor-event edge and columns from (always an actor), to
(always an event), weight, from_mode, and to_mode. The two modes are
disjoint, so no edge joins two actors or two events and self-loops cannot
occur. as.data.frame(x, what = ) also returns nodes (node, mode),
incidence (the wide actor-by-event incidence table: an actor column
followed by one column per event), and a one-row settings table.
Examples
result <- simulate_bipartite_network(actors = 20, events = 6, probability = 0.3, seed = 1)
head(result)
#> <simulab_sim:bipartite_network> 6 rows x 5 columns
#> from to weight from_mode to_mode
#> 1 Actor 4 Event 1 1 actor event
#> 2 Actor 6 Event 1 1 actor event
#> 3 Actor 7 Event 1 1 actor event
#> 4 Actor 15 Event 1 1 actor event
#> 5 Actor 17 Event 1 1 actor event
#> 6 Actor 18 Event 1 1 actor event
#>
#> Truth (settings):
#> probability weight actors events
#> 1 0.3 binary 20 6
#>
#> Other tables: nodes, incidence. Read one with as.data.frame(x, what = "nodes").
components(result)
#> table rows columns
#> 1 data 37 5
#> 2 nodes 26 2
#> 3 incidence 20 7
#> 4 settings 1 4