These functions build social-network and graph structures with named
nodes drawn from the package’s diverse name and learning-state pools.
simulate_igraph() and simulate_network()
return ready-to-plot graph objects across several classic random-graph
models, while simulate_edge_list(),
simulate_long_data(), and
simulate_onehot_data() return tidy data frames for
downstream analysis.
simulate_igraph()Create an igraph object using a chosen random-graph
model (Erdős–Rényi, Barabási–Albert, Watts–Strogatz, SBM, and more),
with named vertices and optional edge weights.
Signature
args(simulate_igraph)
#> function (n = NULL, model = c("er", "ba", "ws", "sbm", "reg",
#> "grg", "ff"), name_source = c("human", "states"), regions = "all",
#> categories = "all", names = NULL, directed = FALSE, weighted = FALSE,
#> weights = c(0.1, 1), p = 0.1, m = NULL, power = 1, m_ba = 2,
#> nei = 2, p_rewire = 0.05, blocks = 3, p_within = 0.3, p_between = 0.05,
#> k = 4, radius = 0.25, fw = 0.35, bw = 0.32, seed = NULL)
#> NULLExample — Erdős–Rényi
g_er <- simulate_igraph(n = 15, model = "er", p = 0.15, seed = 42)
g_er
#> IGRAPH d6f8949 UN-- 15 20 -- Erdos-Renyi (gnp) graph
#> + attr: name (g/c), type (g/c), loops (g/l), p (g/n), name (v/c)
#> + edges from d6f8949 (vertex names):
#> [1] David --Sarnai David --Rashid Arsene--Gunel Rashid--Gunel Arsene--Felipe
#> [6] Diego --Felipe Rashid--Kemal Gunel --Kemal Arsene--Amadou Gunel --Amadou
#> [11] Diego --Amadou Felipe--Amadou Felipe--Juan Rashid--Phong Diego --Tanvir
#> [16] Lukas --Tanvir David --Mia Kemal --Mia Amadou--Mia Lukas --Mia
plot(g_er, vertex.size = 18, vertex.label.cex = 0.7, main = "Erdos-Renyi (n = 15)")Example — Barabási–Albert (scale-free)
g_ba <- simulate_igraph(n = 20, model = "ba", m_ba = 2, seed = 42)
plot(g_ba, vertex.size = 14, vertex.label.cex = 0.6, main = "Barabasi-Albert (n = 20)")Example — Watts–Strogatz (small-world)
g_ws <- simulate_igraph(n = 20, model = "ws", nei = 2, p_rewire = 0.1, seed = 42)
plot(g_ws, vertex.size = 14, vertex.label.cex = 0.6, main = "Watts-Strogatz (n = 20)")simulate_network()Create a statnet network object (same model menu as
simulate_igraph()) with named vertices and optional edge
weights.
Signature
args(simulate_network)
#> function (n = NULL, model = c("er", "ba", "ws", "sbm", "reg",
#> "grg", "ff"), name_source = c("human", "states"), regions = "all",
#> categories = "all", names = NULL, directed = FALSE, weighted = FALSE,
#> weights = c(0.1, 1), p = 0.1, m = NULL, power = 1, m_ba = 2,
#> nei = 2, p_rewire = 0.05, blocks = 3, p_within = 0.3, p_between = 0.05,
#> k = 4, radius = 0.25, fw = 0.35, bw = 0.32, seed = NULL)
#> NULLExample
net <- simulate_network(n = 15, model = "er", seed = 42)
net
#> Network attributes:
#> vertices = 15
#> directed = FALSE
#> hyper = FALSE
#> loops = FALSE
#> multiple = FALSE
#> bipartite = FALSE
#> total edges= 12
#> missing edges= 0
#> non-missing edges= 12
#>
#> Vertex attribute names:
#> vertex.names
#>
#> No edge attributes
plot(net, displaylabels = TRUE, label.cex = 0.7, main = "statnet network (n = 15)")simulate_edge_list()Generate a directed/undirected weighted edge list for social-network analysis, with each node assigned to one of several classes.
Signature
args(simulate_edge_list)
#> function (n_nodes = 20, n_edges = NULL, edge_density = 3, n_classes = 3,
#> directed = TRUE, allow_self_loops = FALSE, weight_range = c(0.1,
#> 1), names = NULL, class_probs = NULL, seed = NULL)
#> NULLExample
edges <- simulate_edge_list(n_nodes = 12, n_classes = 3, seed = 42)
str(edges)
#> 'data.frame': 36 obs. of 4 variables:
#> $ source: chr "Anahera" "Anahera" "Cuauhtemoc" "Cuauhtemoc" ...
#> $ target: chr "Eloise" "Soraya" "Anahera" "Eloise" ...
#> $ weight: num 0.31 0.364 0.913 0.421 0.631 ...
#> $ class : int 3 2 2 1 1 3 2 3 3 1 ...
head(edges)simulate_long_data()Generate hierarchical long-format sequence data (one row per actor-event) with Actor, Achiever, Group, Course, Time, and Action columns — the canonical format for educational-process mining.
Signature
args(simulate_long_data)
#> function (n_groups = 5, n_actors = 10, n_courses = 3, n_states = 9,
#> states = NULL, use_learning_states = TRUE, categories = "group_regulation",
#> seq_length_range = c(10, 30), achiever_levels = c("High",
#> "Low"), achiever_probs = c(0.5, 0.5), start_time = "2025-01-01 10:00:00",
#> time_interval_range = c(60, 600), trans_matrix = NULL, init_probs = NULL,
#> seed = NULL, actors_per_group = NULL, actions = NULL, action_categories = NULL,
#> n_actions = NULL, transition_probs = NULL, initial_probs = NULL)
#> NULLExample
long <- simulate_long_data(n_groups = 3, n_actors = 2, seed = 42)
str(long)
#> tibble [138 × 6] (S3: tbl_df/tbl/data.frame)
#> $ Actor : num [1:138] 1 1 1 1 1 1 1 1 1 1 ...
#> $ Achiever: chr [1:138] "High" "High" "High" "High" ...
#> $ Group : int [1:138] 1 1 1 1 1 1 1 1 1 1 ...
#> $ Course : chr [1:138] "A" "A" "A" "A" ...
#> $ Time : POSIXct[1:138], format: "2025-01-01 10:19:56" "2025-01-01 10:29:47" ...
#> $ Action : chr [1:138] "adapt" "consensus" "synthesis" "discuss" ...
head(long)simulate_onehot_data()Generate the same hierarchical sequence structure as
simulate_long_data() but with each state expanded into its
own one-hot indicator column.
Signature
args(simulate_onehot_data)
#> function (n_groups = 5, n_actors = 10, n_courses = 3, n_states = 9,
#> states = NULL, use_learning_states = TRUE, categories = "group_regulation",
#> seq_length_range = c(10, 30), achiever_levels = c("High",
#> "Low"), achiever_probs = c(0.5, 0.5), start_time = "2025-01-01 10:00:00",
#> time_interval_range = c(60, 600), trans_matrix = NULL, init_probs = NULL,
#> sort_states = FALSE, state_prefix = "", seed = NULL, actors_per_group = NULL,
#> actions = NULL, action_categories = NULL, n_actions = NULL,
#> transition_probs = NULL, initial_probs = NULL)
#> NULLExample
onehot <- simulate_onehot_data(n_groups = 3, n_actors = 2, seed = 42)
dim(onehot)
#> [1] 138 14
str(onehot, list.len = 12)
#> tibble [138 × 14] (S3: tbl_df/tbl/data.frame)
#> $ Actor : num [1:138] 1 1 1 1 1 1 1 1 1 1 ...
#> $ Achiever : chr [1:138] "High" "High" "High" "High" ...
#> $ Group : int [1:138] 1 1 1 1 1 1 1 1 1 1 ...
#> $ Course : chr [1:138] "A" "A" "A" "A" ...
#> $ Time : POSIXct[1:138], format: "2025-01-01 10:19:56" "2025-01-01 10:29:47" ...
#> $ adapt : int [1:138] 1 0 0 0 0 0 0 0 0 0 ...
#> $ consensus : int [1:138] 0 1 0 0 0 0 0 0 0 0 ...
#> $ synthesis : int [1:138] 0 0 1 0 0 0 1 1 1 1 ...
#> $ discuss : int [1:138] 0 0 0 1 1 0 0 0 0 0 ...
#> $ coregulate: int [1:138] 0 0 0 0 0 1 0 0 0 0 ...
#> $ monitor : int [1:138] 0 0 0 0 0 0 0 0 0 0 ...
#> $ cohesion : int [1:138] 0 0 0 0 0 0 0 0 0 0 ...
#> [list output truncated]
head(onehot)