sim_model: Simulate an Item Response Model

View source: R/sim_model.R

sim_modelR Documentation

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 documentation built on Aug. 25, 2022, 5:08 p.m.