simulate_group_sequences: Simulate grouped actor sequences

View source: R/tna.R

simulate_group_sequencesR Documentation

Simulate grouped actor sequences

Description

Simulate grouped actor sequences

Usage

simulate_group_sequences(
  groups = 2L,
  actors = 50L,
  transitions = NULL,
  chain_length = 20L,
  initial = NULL,
  group_names = NULL,
  states = NULL,
  n_states = 5L,
  state_categories = c("metacognitive", "cognitive"),
  seed = NULL,
  ...,
  batch = NULL
)

Arguments

groups

Number of groups, defaulting to 2.

actors

Actors per group, scalar or one value per group, defaulting to 50.

transitions

A common transition matrix, one matrix per group, or NULL for randomly generated matrices. A tidy data frame with columns group, from, to and probability gives one matrix per group.

chain_length

Sequence length, defaulting to 20.

initial

Common initial probabilities, one vector per group, or NULL. A tidy data frame with columns group, state and probability gives one vector per group.

group_names

Optional group labels.

states, n_states, state_categories

State-space arguments passed to simulate_sequences().

seed

Optional random seed. Group-specific deterministic offsets are used without leaking RNG state.

...

Advanced sequence arguments passed to simulate_sequences().

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 long-form simulab_sim base data.frame with one row per actor sequence position and columns group, id, period, and state. Actor identifiers are made unique across groups as ⁠G<group>_A<actor>⁠. as.data.frame(x, what = ) also returns transitions (group, from, to, probability), wide (one row per actor: id, S1, S2, ..., group), and groups (group, actors).

Examples

result <- simulate_group_sequences(
  groups = 2, actors = 20, chain_length = 12, n_states = 3, seed = 1
)
head(result)
components(result)

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