Learn R Programming

guess (version 0.7.0)

simulate_lca_dk: Simulate Pre-Post Test Data (DK Model)

Description

Generates simulated pre/post test data from a latent class model with Don't Know responses.

Usage

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
)

Value

List with two data frames:

pre

Pre-test responses (character: "0", "1", or "d")

post

Post-test responses (character: "0", "1", or "d")

Arguments

n

Integer. Number of individuals to simulate.

n_items

Integer. Number of test items. Default 1.

gg

Numeric. Proportion: guess->guess (stable ignorance). Default 0.25.

gk

Numeric. Proportion: guess->know (learned). Default 0.15.

gd

Numeric. Proportion: guess->dk. Default 0.10.

kk

Numeric. Proportion: know->know (stable knowledge). Default 0.15.

dg

Numeric. Proportion: dk->guess. Default 0.10.

dk

Numeric. Proportion: dk->know (learned). Default 0.10.

dd

Numeric. Proportion: dk->dk. Default 0.15.

gamma

Numeric. Probability of guessing correctly. Can be scalar (same for all items) or vector of length n_items. Default 0.25.

difficulty

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.

base_rate

Numeric. Minimum guessing probability (random chance). Used when difficulty is specified. Default 0.25 (1/4 for 4-choice items).

seed

Optional integer. Random seed for reproducibility.

Details

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).

Examples

Run this code
# 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

# 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)

Run the code above in your browser using DataLab