Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sim_model

Simulate an Item Response Model


Description

Simulates an item response model given a fitted object or input of item response probabilities and skill class probabilities.

Usage

sim_model(object=NULL, irfprob=NULL, theta_index=NULL, prob.theta=NULL,
      data=NULL, N_sim=NULL )

Arguments

object

Fitted object for which the methods IRT.posterior, and IRT.data are defined.

irfprob

Array of item response function values (items \times categories \times skill classes)

theta_index

Skill class index for sampling

prob.theta

Skill class probabilities

data

Original dataset, only relevant for simulating item response pattern with missing values

N_sim

Number of subjects to be simulated

Value

List containing elements

dat

Simulated item responses

theta

Simulated skill classes

theta_index

Corresponding indices to theta

Examples

## Not run: 
#############################################################################
# EXAMPLE 1: GDINA model simulation
#############################################################################

data(sim.dina, package="CDM")
data(sim.qmatrix, package="CDM")
dat <- sim.dina
Q <- sim.qmatrix

# fit DINA model
mod <- CDM::gdina( dat, q.matrix=Q, rule="DINA")
summary(mod)

#** simulate new item responses (N equals observed sample size)
dat1 <- CDM::sim_model(mod)

#*** simulate item responses for N=2000 subjects
dat2 <- CDM::sim_model(mod, N_sim=2000)
str(dat2)

#*** simulate item responses based on input item response probabilities
#*** and theta_index
irfprob <- CDM::IRT.irfprob(mod)
prob.theta <- attr(irfprob, "prob.theta")
TP <- length(prob.theta)
theta_index <- sample(1:TP, size=1000, prob=prob.theta, replace=TRUE )
#-- simulate
dat3 <- CDM::sim_model(irfprob=irfprob, theta_index=theta_index)
str(dat3)

## End(Not run)

CDM

Cognitive Diagnosis Modeling

v7.5-15
GPL (>= 2)
Authors
Alexander Robitzsch [aut, cre], Thomas Kiefer [aut], Ann Cathrice George [aut], Ali Uenlue [aut]
Initial release
2020-03-10 14:19:21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.