Generates simulated pre/post test data from a latent class model with Don't Know responses.
simulate_lca_dk(
n,
n_items = 1,
gg = 0.25,
gk = 0.15,
gd = 0.1,
kk = 0.15,
dg = 0.1,
dk = 0.1,
dd = 0.15,
gamma = 0.25,
difficulty = NULL,
base_rate = 0.25,
seed = NULL
)Integer. Number of individuals to simulate.
Integer. Number of test items. Default 1.
Numeric. Proportion: guess->guess (stable ignorance). Default 0.25.
Numeric. Proportion: guess->know (learned). Default 0.15.
Numeric. Proportion: guess->dk. Default 0.10.
Numeric. Proportion: know->know (stable knowledge). Default 0.15.
Numeric. Proportion: dk->guess. Default 0.10.
Numeric. Proportion: dk->know (learned). Default 0.10.
Numeric. Proportion: dk->dk. Default 0.15.
Numeric. Probability of guessing correctly. Can be scalar (same for all items) or vector of length n_items. Default 0.25.
Numeric vector. Optional difficulty-link scores. If provided, gamma is computed as base_rate + (1 - base_rate) * plogis(-difficulty). Higher difficulty = harder item (lower gamma). Ignored if NULL.
Numeric. Minimum guessing probability (random chance). Used when difficulty is specified. Default 0.25 (1/4 for 4-choice items).
Optional integer. Random seed for reproducibility.
List with two data frames:
Pre-test responses (character: "0", "1", or "d")
Post-test responses (character: "0", "1", or "d")
The DK model has 7 latent classes representing transitions between guess (g), know (k), and don't know (d) states: - **gg**: guess both times - **gk**: guess -> know (learned) - **gd**: guess -> dk - **kk**: know -> know - **dg**: dk -> guess - **dk**: dk -> know (learned) - **dd**: dk -> dk
The know -> guess and know -> dk classes are absent by design. The model is identified by the assumption that people do not lose knowledge over a short informative process, which sets both to zero. Learning is gk + dk.
Parameters must sum to 1 (constraint enforced automatically).
When difficulty is specified, gamma values are derived using a logistic transformation: gamma_i = base_rate + (1 - base_rate) * plogis(-difficulty_i).
# Simulate DK data
sim <- simulate_lca_dk(n = 5000, gk = 0.15, seed = 123)
fit <- item_lca_fit(sim$pre, sim$post)
fit$params["gk", ] # Should be close to 0.15
#> [1] 0.1579976
# Item-specific gamma (vector)
sim_vec <- simulate_lca_dk(n = 500, n_items = 3, gamma = c(0.2, 0.25, 0.3), seed = 456)
# Difficulty-link scores
sim_irt <- simulate_lca_dk(n = 500, n_items = 3, difficulty = c(1, 0, -1), seed = 789)