Skip to contents

Simulates item response data from 1PL, 2PL, or 3PL logistic IRT models. Returns a long-format data frame with id, item, and resp columns.

Usage

irw_simdata(
  n_id = 1000,
  n_item = 20,
  model = "1PL",
  a = NULL,
  b = NULL,
  g = NULL,
  theta = NULL,
  theta_mean = 0,
  theta_sd = 1,
  seed = NULL,
  return_params = FALSE
)

Arguments

n_id

Number of respondents. Ignored if theta is provided. Default is 1000.

n_item

Number of items. Default is 20.

model

Character string: one of "1PL", "2PL", or "3PL". Default is "1PL".

a

Optional vector of item discriminations. If NULL, sampled from lognormal(0.2, 0.2) (ignored for 1PL).

b

Optional vector of item difficulties. If NULL, sampled from N(0, 1).

g

Optional vector of guessing parameters. Required for 3PL; if NULL, sampled from Beta(5, 17).

theta

Optional vector of person abilities. If provided, overrides n_id, theta_mean, and theta_sd.

theta_mean

Mean of theta distribution (if theta not supplied). Default is 0.

theta_sd

Standard deviation of theta distribution. Default is 1.

seed

Optional integer for reproducibility.

return_params

Logical. If TRUE, returns a list with data and parameters. Default is FALSE.

Value

A data frame with columns id, item, resp, or a list with additional parameters if return_params = TRUE.

Examples

if (FALSE) { # \dontrun{
# 1PL (default)
dat <- irw_simdata(n_item = 5)

# 3PL with latent traits drawn from N(-0.5, 1)
sim <- irw_simdata(n_item = 5, model = "3PL", theta_mean = -0.5, return_params = TRUE)
head(sim$data)
} # }