| simulate_sequences | R Documentation |
Simulate basic or perturbed state sequences
simulate_sequences(
n = 100L,
transition = NULL,
chain_length = 20L,
initial = NULL,
states = NULL,
n_states = 5L,
state_categories = c("metacognitive", "cognitive"),
concentration = 1,
missing_tail = c(0L, 0L),
stable_transitions = NULL,
stability_probability = 0.95,
instability = c("none", "random_jump", "perturb", "unlikely_jump"),
instability_probability = 0.4,
perturbation = 0.5,
unlikely_threshold = 0.1,
seed = NULL,
batch = NULL
)
n |
Number of sequences, defaulting to |
transition |
Optional transition matrix. When |
chain_length |
Maximum sequence length, defaulting to |
initial |
Initial probabilities or a fixed starting state. When |
states |
State labels. |
n_states |
Number of automatically generated states. |
state_categories |
Learning-state categories that name a generated state
space, defaulting to |
concentration |
Positive Dirichlet concentration used for automatic transition and initial probabilities. |
missing_tail |
Number or range of trailing positions removed from each sequence. |
stable_transitions |
Optional two-column data frame named |
stability_probability |
Probability of following a preferred transition. |
instability |
Instability mechanism for other transitions. |
instability_probability |
Probability of applying that mechanism. |
perturbation |
Multiplicative probability perturbation magnitude. |
unlikely_threshold |
Maximum probability considered unlikely. |
seed |
Optional random seed. |
batch |
Optional single positive whole number. When given, the
simulator runs |
A long-form simulab_sim base data.frame with columns id,
period, and state, one row per observed sequence position.
as.data.frame(x, what = ) also returns transitions (from, to,
probability, row-stochastic in from), initial_probabilities
(state, probability), wide (one row per sequence, columns id,
S1, S2, ...), and a one-row settings table.
result <- simulate_sequences(n = 40, n_states = 4, chain_length = 20, seed = 1)
head(result)
components(result)
# With no arguments, a random transition matrix is drawn and reported.
drawn <- simulate_sequences(seed = 1)
as.data.frame(drawn, what = "transitions")
# Preferred transitions followed with a given probability.
stable <- data.frame(
from = sprintf("State %d", 1:4),
to = sprintf("State %d", c(2, 3, 4, 1))
)
head(simulate_sequences(
n = 40, n_states = 4, chain_length = 20, state_categories = NULL,
stable_transitions = stable, stability_probability = 0.85, seed = 1
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.