| aib_simulate | R Documentation |
Generates a panel of repeated 0/1 decisions that follow a two-state Markov chain within each group, and optionally hides decisions with a probability that depends on the group and on the unit's previous (true) decision. Useful for checking an audit against known components and for teaching.
aib_simulate(
n = 500,
n_times = 4,
groups = c("reference", "focal"),
init = c(0.5, 0.5),
p01 = c(0.2, 0.1),
p11 = c(0.8, 0.7),
observe = NULL,
unobserved = c("na", "drop"),
seed = NULL
)
n |
Integer. Units per group (scalar, or one value per group). |
n_times |
Integer. Number of occasions (at least 2). |
groups |
Character. Group labels; the first is used as the reference group in the examples. |
init |
Numeric. Probability of a favorable first decision, one per group. |
p01 |
Numeric. Recovery probability |
p11 |
Numeric. Retention probability |
observe |
NULL for complete observation, or a 2-row matrix of observation probabilities with one column per group: row 1 after an unfavorable previous decision, row 2 after a favorable one. The first occasion is always observed. |
unobserved |
Character. '"na"' (default) keeps unobserved occasions as rows with a missing decision; '"drop"' removes them. |
seed |
Integer or NULL. Random seed. |
A data frame with columns 'id', 'time', 'group', 'decision' and 'decision_true' (the decision before any hiding).
# Equal recovery and retention gaps (zero amplification index),
# yet the approval gap widens.
sim <- aib_simulate(n = 2000, n_times = 4, groups = c("ref", "focal"),
init = c(0.5, 0.5), p01 = c(0.2, 0.1),
p11 = c(0.8, 0.7), seed = 1)
obj <- aib_build(sim, "id", "time", "group", "decision", verbose = FALSE)
obj <- aib_decompose(obj, ref_group = "ref")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.