simulate_network_matrix: Simulate a network matrix

View source: R/network_formats.R

simulate_network_matrixR Documentation

Simulate a network matrix

Description

Simulate a network matrix

Usage

simulate_network_matrix(
  nodes,
  type = c("adjacency", "transition", "frequency", "cooccurrence"),
  probability = 0.2,
  directed = TRUE,
  loops = FALSE,
  weighted = TRUE,
  weight_range = c(0.1, 1),
  frequency_mean = 10,
  seed = NULL,
  batch = NULL
)

Arguments

nodes

Number of nodes or unique node labels.

type

Matrix type.

probability

Probability of a non-zero dyad.

directed

Generate an asymmetric matrix where applicable.

loops

Permit non-zero diagonal entries.

weighted

Generate weighted adjacency/co-occurrence values. Ignored by the frequency and transition types, which are always weighted.

weight_range

Range for continuous weights.

frequency_mean

Mean positive count for frequency matrices; drawn as 1 + rpois(frequency_mean - 1), so entries are at least one.

seed

Optional seed.

batch

Optional single positive whole number. When given, the simulator runs batch times and returns a plain list of batch results, each exactly what the same call without batch returns. With a seed, every dataset gets its own seed drawn from seed, so the whole batch is reproducible; without one the datasets are consecutive draws from the session's random-number stream. The default NULL returns a single result.

Value

A tidy simulab_sim base data.frame holding the complete matrix in long form: nodes^2 rows with columns from, to, and value, zeros included. as.data.frame(x, what = ) also returns edges (the non-zero rows only), nodes (node), matrix (the wide form: a from column followed by one column per node), and a one-row settings table whose directed field reports whether the generated matrix is asymmetric. The transition type is row-stochastic: every from state's value entries sum to one.

Examples

result <- simulate_network_matrix(nodes = 8, type = "adjacency", seed = 1)
head(result)
components(result)

simulab documentation built on Oct. 15, 2026, 5:08 p.m.