Learn R Programming

irt (version 0.1.1)

prob: Calculate the probability of a correct response

Description

prob Returns the probability of correct respond to an item or multiple items with given parameters for a given ability or abilities, i.e. \(\theta\). For polytomous models, where there are multiple possible responses, probability of each response category will be returned.

Usage

prob(ip, theta, derivative = 0, expected_value = FALSE)

# S4 method for Item prob(ip, theta, derivative = 0, expected_value = FALSE)

# S4 method for Itempool prob(ip, theta, derivative = 0, expected_value = FALSE)

# S4 method for Testlet prob(ip, theta, derivative = 0, expected_value = FALSE)

# S4 method for numMatDfListChar prob(ip, theta, derivative = 0, expected_value = FALSE)

Arguments

ip

An Item-class or an Itempool-class object containing the item parameters.

theta

An object containing the ability parameters.

derivative

Whether to calculate the first or second derivative of probability of a response.

0

No derivative will be calculated. This is the default value.

1

Calculate the first derivative.

2

Calculate the second derivative.

expected_value

For each possible response value, the probability of that response is calculated and summed to get the expected value at a theta value. Default value is FALSE.

Value

Item probabilities at given theta will be returned. If expected_value is TRUE, the expected value(s) of item or item pool at a given theta value will be returned.

Examples

Run this code
# NOT RUN {
theta <- rnorm(1)
item1 <- generate_item(model = "2PL")

# Probability of correct response
prob(item1, theta)

# First derivative of probability of correct response:
prob(item1, theta, derivative = 1)

# Second derivative of probability of correct response:
prob(item1, theta, derivative = 2)

# Probability of each response category for Generalized Partial Credit Model
item2 <- generate_item(model = "GPCM", n_categories = 4)
prob(item2, theta)

# First derivative of each response category
prob(item2, theta, derivative = 1)

# Second derivative of each response category
prob(item2, theta, derivative = 2)

# Expected score for a subject with a given theta value
prob(item2, theta, expected_value = TRUE)

# Multiple theta values
theta_n <- rnorm(5)

prob(item1, theta_n)
prob(item1, theta_n, derivative = 1)
prob(item1, theta_n, derivative = 2)

prob(item2, theta_n)
prob(item2, theta_n, derivative = 1)
prob(item2, theta_n, derivative = 2)


theta <- rnorm(1)
ip <- generate_ip(model = "3PL")

# Probability of correct response
prob(ip, theta)

# First derivative of probability of correct response:
prob(ip, theta, derivative = 1)

# Second derivative of probability of correct response:
prob(ip, theta, derivative = 2)

# Multiple theta
theta_n <- rnorm(5)
prob(ip, theta_n)
prob(ip, theta_n, derivative = 1)
prob(ip, theta_n, derivative = 2)


# Probability of each response category for Generalized Partial Credit Model
ip <- generate_ip(model = "GPCM", n = 4, n_categories = c(3, 4, 6, 5))
prob(ip, theta)

# First derivative of each response category
prob(ip, theta, derivative = 1)

# Second derivative of each response category
prob(ip, theta, derivative = 2)

# Expected score for a subject with a given theta value for each item
prob(ip, theta, expected_value = TRUE)

# Probability of a mixture of items models
ip <- generate_ip(model = c("GPCM", "2PL", "3PL", "GPCM"),
                  n_categories = c(4, 2, 2, 3))
prob(ip, theta)

theta <- rnorm(1)
t1 <- generate_testlet(model_items = "3PL")

# Probability of correct response
prob(t1, theta)

# First derivative of probability of correct response:
prob(t1, theta, derivative = 1)

# Second derivative of probability of correct response:
prob(t1, theta, derivative = 2)

# }

Run the code above in your browser using DataLab