sim_model.Rd
Simulates an item response model given a fitted object or input of item response probabilities and skill class probabilities.
sim_model(object=NULL, irfprob=NULL, theta_index=NULL, prob.theta=NULL,
data=NULL, N_sim=NULL )
Fitted object for which the methods IRT.posterior
,
and IRT.data
are defined.
Array of item response function values (items \(\times\) categories \(\times\) skill classes)
Skill class index for sampling
Skill class probabilities
Original dataset, only relevant for simulating item response pattern with missing values
Number of subjects to be simulated
List containing elements
Simulated item responses
Simulated skill classes
Corresponding indices to theta
if (FALSE) {
#############################################################################
# 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)
}