Takes or draws a transition matrix, generates sequences from it with
simulate_sequences(), and fits one transition network to the sequences
with the tna package, all in one call.
Arguments
- n
Number of sequences, defaulting to
100.- transition
Generating transition matrix, or a tidy data frame with columns
from,toandprobability.NULL(the default) draws one overn_statesstates from a Dirichlet distribution.- chain_length
Sequence length, defaulting to
20.- initial
Initial probabilities or a fixed starting state. When
NULLandtransitionis supplied, every sequence starts in the first state.- states
State labels.
- n_states
Number of automatically generated states.
- state_categories
Learning-state categories the labels of a drawn matrix come from, defaulting to
c("metacognitive", "cognitive"); seelearning_state_categories().NULLlabels the statesState 1,State 2, and so on. Ignored whentransitionorstatesnames the states.- model
TNA estimator, one of
"tna"(the default),"ftna","ctna"or"atna".- seed
Optional random seed. A single number makes the call reproducible and restores the session's random-number state afterwards;
NULL(the default) draws from the session's stream and advances it.- ...
Further arguments passed to
simulate_sequences(), such asconcentrationormissing_tail.- 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
The fitted network as a native tna model, of class
c("simulab_tna", "tna"), so every tna function (plot(),
centralities(), summary() and the rest) applies to it. Printing it
shows the native tna print, then the generating transition matrix and
initial probabilities. Tidy tables come from as.data.frame():
the fitted edges (the default; columns from, to and weight), the
generating transitions (columns from, to and probability),
initial_probabilities, the generated sequences in long form, wide
and model_info. Requires the suggested tna package, and raises
simulab_missing_tna without it.
References
Saqr, M., López-Pernas, S., Törmänen, T., Kaliisa, R., Misiejuk, K., & Tikka, S. (2025). Transition network analysis: A novel framework for modeling, visualizing, and identifying the temporal patterns of learners and learning processes. In Proceedings of the 15th International Learning Analytics and Knowledge Conference (pp. 351–361). doi:10.1145/3706468.3706513
Examples
if (requireNamespace("tna", quietly = TRUE)) {
# With no arguments: a drawn 5-state system, 100 sequences, one network.
network <- simulate_tna(seed = 1)
network
validate_recovery(network, network, term = "to", estimate = "weight")
# From a given transition matrix.
transition <- data.frame(
from = rep(c("plan", "act"), each = 2),
to = rep(c("plan", "act"), times = 2),
probability = c(0.3, 0.7, 0.6, 0.4)
)
simulate_tna(n = 200, transition = transition, seed = 1)
}