| simulate_group_tna | R Documentation |
Simulate sequences and fit a grouped TNA model
simulate_group_tna(
groups = 2L,
actors = 50L,
transitions = NULL,
chain_length = 20L,
initial = NULL,
group_names = NULL,
states = NULL,
n_states = 5L,
state_categories = c("metacognitive", "cognitive"),
model = c("tna", "ftna", "ctna", "atna"),
seed = NULL,
...,
batch = NULL
)
groups |
Number of groups, defaulting to |
actors |
Actors per group, scalar or one value per group, defaulting
to |
transitions |
A common transition matrix, one matrix per group, or
|
chain_length |
Sequence length, defaulting to |
initial |
Common initial probabilities, one vector per group, or
|
group_names |
Optional group labels. |
states, n_states, state_categories |
State-space arguments passed to
|
model |
TNA model type. |
seed |
Optional random seed. Group-specific deterministic offsets are used without leaking RNG state. |
... |
Advanced sequence arguments. |
batch |
Optional single positive whole number. When given, the
simulator runs |
A long-form simulab_sim base data.frame of grouped sequences with
columns group, id, period, and state.
as.data.frame(x, what = ) also returns true_transitions (the
generating probabilities), estimated_edges (the fitted TNA weights),
model_info, wide, and groups. The native group_tna model is
accessible through as_tna_model(). Requires the suggested tna package.
if (requireNamespace("tna", quietly = TRUE)) {
result <- simulate_group_tna(
groups = 2, actors = 20, chain_length = 12, n_states = 3, seed = 1
)
head(result)
components(result)
# With no arguments, one transition matrix per group is drawn and fitted.
drawn <- simulate_group_tna(seed = 1)
as.data.frame(drawn, what = "true_transitions")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.