simIrt: Simulate Responses to IRT Models

View source: R/simIrt.R

simIrtR Documentation

Simulate Responses to IRT Models

Description

simIrt simulates responses to various IRT models given a vector of ability values and a vector/matrix of item parameters.

Usage

simIrt( theta = seq(-3, 3, by = 0.1), params, mod = c("brm", "grm") )

Arguments

theta

numeric: a vector of ability values, one for each simulee.

params

numeric: a vector or matrix of item parameters. If specified as a matrix, the rows must index the items, and the columns must designate the item parameters. For the binary response model, ("brm"), params must either be a 3-element vector or a 3-column matrix. See Details for more information.

mod

character: a character string indicating the IRT model. Current support is for the 3-parameter binary response model ("brm"), and Samejima's graded response model ("grm"). The contents of params must match the designation of mod. See Details for more information.

Details

The function simIrt returns a response matrix of class "brm" or "grm" depending on the model. For the binary response model, the probability of endorsing item j for simulee i is the following (Embretson & Reise, 2000):

p_{ij} = c_j + (1 - c_j)/(1 + \exp[-a(θ - b)])

For the graded response model, the probability of endorsing at or above boundary k of item j for simulee i is the following:

p_{ijk} = 1/(1 + \exp[-a(θ - b_k)])

so that the probability of scoring in category k is, P_{ijk} = Pr(u_{ij} = k | θ_i, a_j, \boldsymbol{b}) = 1 - p_{ijk} if k = 1; p_{ijk} if k = K; and p_{ij(k - 1)} - p_{ijk} otherwise, where K is the number of categories, so that K - 1 is the number of boundaries.

Assuming perfect model fit, simIrt generates the probability of responding in a category, simulates a random, uniform deviate, and compares the probability of response with the location of the deviate. For instance, for the binary response model, if p_{ij} = .7, so that q_{ij} = 1 - p_{ij} = .3, simIrt will generate a uniform deviate (u_{ij}) between 0 and 1. If u_{ij} < p_{ij}, the simulee will score a 1, and otherwise, the simulee will score a 0.

Value

The function simIrt returns a list of the following elements:

resp

a matrix of class "brm" or "grm" depending on the model used. The dimensions of the matrix will be N \times J (persons by items), and will contain 0s and 1s for the binary response model or 1 … K for the graded response model, where K indicates the number of categories.

params

a matrix of class "brm" or "grm" containing the item parameters used in the simulation. In the case of "grm", the threshold parameters will be ordered so that they will work in other functions.

theta

a vector of theta used in the simulation. If theta is not specified by the user, it will default to a 201-length vector of evenly spaced points between -3 and 3.

Author(s)

Steven W. Nydick swnydick@gmail.com

References

Embretson, S. E., & Reise, S. P. (2000). Item Response Theory for Psychologists. Mahway, NJ: Lawrence Erlbaum Associates.

Samejima, F. (1969). Estimation of latent ability using a response pattern of graded scores. Psychometrika Monograph Supplement, 34, 100 – 114.

van der Linden, W. J. & Hambleton, R. K. (2010). Handbook of Modern Item Response Theory. New York, NY: Springer.

See Also

catIrt

Examples

#########################
# Binary Response Model #
#########################
set.seed(888)
# generating an item bank under a binary response model:
b.params <- cbind(a = runif(100, .5, 1.5), b = rnorm(100, 0, 2), c = .2)
# simulating responses using default theta:
b.mod <- simIrt(params = b.params, mod = "brm")

# same type of model without a guessing (c) parameter:
b.params2 <- cbind(a = runif(100, .5, 1.5), b = rnorm(100, 0, 2), c = 0)
b.mod2 <- simIrt(params = b.params2, mod = "brm")

# now generating a different theta:
theta <- rnorm(201)
b.mod3 <- simIrt(theta = theta, params = b.params2, mod = "brm")

# notice all of the responses are 0 or 1:
unique(as.vector(b.mod$resp))

# and the percentages (in general) increase as theta increases:
apply(b.mod$resp, 1, mean)    # theta = seq(-3, 3, by = 0.1)


#########################
# Graded Response Model #
#########################
set.seed(999)
# generating an item bank under a graded response model:
# (as many categories as your heart desires!)
g.params <- cbind(a = runif(10, .5, 1.5), b1 = rnorm(10), b2 = rnorm(10),
                                          b3 = rnorm(10))
# simulating responses using default theta (automatically sorts boundaries):
g.mod <- simIrt(params = g.params, mod = "grm")

# notice how the old parameters were not sorted:
g.params
# but the new parameters are sorted from column 2 on:
g.mod$params

# don't use these parameters with the binary response model:
try(simIrt(params = g.params, mod = "brm"), silent = TRUE)[1]

# a better parameter set for the graded response model:
g.params2 <- cbind(runif(100, .5, 1.5), b1 = runif(100, -2, -1), b2 = runif(100, -1, 0),
                                        b3 = runif(100, 0, 1), b4 = runif(100, 1, 2))
g.mod2 <- simIrt(params = g.params2, mod = "grm")

# notice all of the responses are positive integers:
unique(as.vector(g.mod$resp))
unique(as.vector(g.mod2$resp))

# and the responses (in general) increase as theta increases:
apply(g.mod2$resp, 1, mean)

swnydick/catIrt documentation built on June 13, 2022, 9:30 p.m.