| simulate_irt | R Documentation |
Draws latent abilities from a standard multivariate normal (mean zero, unit
variance, correlation ability_correlation), projects them onto each item
through dimensions, and samples responses from a logistic item-response
model.
simulate_irt(
n,
discrimination = 1,
difficulty,
dimensions = NULL,
ability_correlation = NULL,
model = c("2pl", "rasch", "3pl", "graded"),
guessing = 0.2,
seed = NULL,
batch = NULL
)
n |
Number of respondents. A single whole number of at least 2. |
discrimination |
Positive item discriminations, a scalar recycled
across items (the default, |
difficulty |
Item difficulties, on the same scale as the latent
ability. A numeric vector, one difficulty per item, for the dichotomous
models. |
dimensions |
Item-by-dimension loading weights, or a tidy data frame
with columns |
ability_correlation |
Latent ability correlation matrix, or a tidy
data frame with columns |
model |
Logistic model: |
guessing |
Lower-asymptote guessing parameters in |
seed |
Optional random seed. |
batch |
Optional single positive whole number. When given, the
simulator runs |
For the dichotomous models the probability of a correct response is
guessing + (1 - guessing) * plogis(discrimination * (theta - difficulty)),
so difficulty is on the ability scale (the point of inflection), not an
intercept. "rasch" fixes all discriminations at one and "2pl" sets
guessing to zero; only "3pl" uses guessing.
For model = "graded" the cumulative category probabilities are
plogis(discrimination * (theta - threshold)) for each threshold of an
item, and the category probabilities are their successive differences, so
the thresholds are also on the ability scale.
A simulab_sim base data.frame with one row per respondent and
columns id and one integer column per item, coded 0/1 for the
dichotomous models and 0 to the number of thresholds for
model = "graded". An abilities component holds one row per respondent
with columns id and one true ability per dimension. A parameters
component holds one row per item for the dichotomous models, with columns
item, parameter ("difficulty"), category (NA), value,
discrimination and guessing; for model = "graded" it holds one row
per item-by-threshold combination, with parameter equal to
"threshold", category the threshold index, and no guessing column.
result <- simulate_irt(
n = 200,
discrimination = c(1, 1.2, 0.8),
difficulty = c(-1, 0, 1),
seed = 1
)
head(result)
as.data.frame(result, what = "parameters")
# Three-parameter logistic with a guessing floor.
head(simulate_irt(
n = 200,
discrimination = c(1, 1.2, 0.8),
difficulty = c(-1, 0, 1),
model = "3pl",
guessing = 0.2,
seed = 1
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.