sim_resp {irt}R Documentation

Generate responses for a given model

Description

sim_resp Generate dichotomous (0 or 1) or polytomous responses for given ability and item parameter.

Usage

sim_resp(ip, theta, prop_missing = 0, output = "matrix")

## S4 method for signature 'Item'
sim_resp(ip, theta, prop_missing = 0, output = "matrix")

## S4 method for signature 'Testlet'
sim_resp(ip, theta, prop_missing = 0, output = "matrix")

## S4 method for signature 'Itempool'
sim_resp(ip, theta, prop_missing = 0, output = "matrix")

## S4 method for signature 'numMatDfListChar'
sim_resp(ip, theta, prop_missing = 0, output = "matrix")

Arguments

ip

An Item-class, Itempool-class, Testlet-class object containing the item parameters.

theta

An object containing the subject ability parameters.

prop_missing

Proportion of responses that should be missing. Default value is 0. This argument is valid for only Itempool-class and Testlet-class objects.

output

Type of the output. Following options are available:

"matrix"

A matrix object.

"response_set"

A Response_set-class object with item pool attached.

Value

A vector of responses.

Author(s)

Emre Gonulates

Examples

## Simulate Responses for an Item object ##
item <- generate_item(model = "3PL")
sim_resp(ip = item, theta = rnorm(1))

item <- generate_item(model = "GPCM")
sim_resp(ip = item, theta = rnorm(1))


item <- generate_item(model = "GRM")
sim_resp(ip = item, theta = rnorm(1))

## Simulate Responses for a Testlet object ##
# Create a testlet
testlet <- testlet(c(item(b = 1), item(a = .8, b = 3.1),
                   item(b = -1:1, model = "PCM")))
sim_resp(ip = testlet, theta = rnorm(1))
## Simulate Responses for an Itempool object ##
# Create 3PL IRT item parameters
ip <- itempool(a = rlnorm(10, 0, 0.3), b = rnorm(10), c = runif(10, 0, .3))
# Simulate responses for one theta:
sim_resp(ip = ip, theta = rnorm(1))
# Simulate responses for eight thetas:
sim_resp(ip = ip, theta = rnorm(8))

# Create Graded Response Model Parameters
ip <- generate_ip(n = 5, model = "GRM", n_categories = c(3, 4, 8, 5, 4))
# Simulate responses for one theta:
sim_resp(ip = ip, theta = rnorm(1))
# Simulate responses for 5 thetas:
sim_resp(ip = ip, theta = rnorm(5))
# Set 10% of the item responses as missing
sim_resp(ip = ip, theta = rnorm(5), prop_missing = .1)

[Package irt version 0.2.9 Index]