sim.PCM {WrightMap} | R Documentation |
Simulate Item Responses for Partial Credit and Rasch Models with Varying Levels
Description
Simulate polytomous item responses based on item difficulty thresholds (delta
) and person abilities (theta
) for the Partial Credit Model (PCM) and the Rasch Model as a special case. The function allows items to have varying numbers of levels, making it useful for generating data in contexts such as item response theory (IRT) models for polytomous items (e.g., Likert scales).
Usage
sim.PCM(pN, iN, lN, itemLevels = NULL, delta = NULL, delta.l = NULL, theta = NULL)
Arguments
pN |
|
iN |
|
lN |
|
itemLevels |
|
delta |
|
delta.l |
|
theta |
|
Details
This function generates polytomous item responses using a logistic IRT model. It first creates or uses given person abilities (theta
) and item thresholds (delta
). Responses are simulated by computing the probability of a person responding in each category of an item based on their ability and the item's threshold. The function allows for items to have different numbers of response categories through the itemLevels
argument.
Value
A list with the following components:
pN |
The number of people (respondents). |
iN |
The number of items. |
lN |
The default number of levels (categories) for the polytomous items. |
itemLevels |
A vector specifying the number of levels for each item. |
M |
A list of |
CM |
A list of |
U |
A |
theta |
A numeric vector of person abilities. |
delta.l |
(Optional) A vector of common level thresholds if it was generated internally. |
delta.il |
(Optional) A matrix of item-specific deviations for thresholds if |
delta |
A matrix of item thresholds. |
resp |
A |
Author(s)
David Torres Irribarra
See Also
Examples
# Simulate 100 respondents, 5 items, and 3 levels (e.g., Likert scale with 3 options)
simulated_data <- sim.PCM(pN = 100, iN = 5, lN = 3)
# Simulate with custom item thresholds
custom_delta <- matrix(c(-0.5, -1, -2, 1, 0.5, 1), nrow = 3)
simulated_data_custom <- sim.PCM(pN = 50, iN = 3, lN = 3, delta = custom_delta)
# Simulate with custom person abilities
custom_theta <- rnorm(100, mean = 0, sd = 1.5)
simulated_data_theta <- sim.PCM(pN = 100, iN = 5, lN = 3, theta = custom_theta)
# Rasch model simulation (dichotomous items)
# 50 persons with abilities ranging from -3 to 3
rasch_theta <- seq(-3, 3, length.out = 50)
rasch_delta <- matrix(c(0,1.5,0,-1,0,0.5,0,-0.5,0,1,0,-1.5,0,2,0,-2,0,0.8,0,-0.8)
, ncol = 2, byrow = TRUE)
simulated_rasch <- sim.PCM(pN = 50, iN = 10, lN = 2, delta = rasch_delta, theta = rasch_theta)
# Simulation with items having different numbers of levels
# 4 items with 5 levels, 3 items with dichotomous responses, and 3 items with 3 levels
# Simulate with a total of 10 items and varying levels
simulated_mixed_levels <- sim.PCM(pN = 50, iN = 10, lN = 5,
itemLevels = c(5, 5, 5, 5, 2, 2, 2, 3, 3, 3))