Learn R Programming

hmcdm (version 2.1.2)

sim_hmcdm: Simulate responses from the specified model (entire cube)

Description

Simulate a cube of responses from the specified model for all persons on items across all time points. Currently available models are DINA, rRUM, and NIDA.

Usage

sim_hmcdm(
  model,
  alphas,
  Q_matrix,
  Design_array,
  itempars = NULL,
  r_stars = NULL,
  pi_stars = NULL,
  Svec = NULL,
  Gvec = NULL
)

Value

An array of item responses from the specified model of examinees across all time points.

Arguments

model

The cognitive diagnostic model under which the item responses are generated

alphas

An N-by-K-by-L array of attribute patterns of all persons across L time points

Q_matrix

A J-by-K of Q-matrix

Design_array

A N-by-J-by-L array indicating whether item j is administered to examinee i at l time point.

itempars

A J-by-2 mat of item parameters (slipping: 1st col, guessing: 2nd col).

r_stars

A J-by-K mat of item penalty parameters for missing skills.

pi_stars

A length J vector of item correct response probability with all requisite skills.

Svec

A length K vector of slipping probability in applying mastered skills

Gvec

A length K vector of guessing probability in applying mastered skills

Examples

Run this code
# \donttest{
## DINA ##
N = nrow(Design_array)
J = nrow(Q_matrix)
thetas_true = rnorm(N, 0, 1.8)
lambdas_true <- c(-2, .4, .055)
Alphas <- sim_alphas(model="HO_joint", 
                    lambdas=lambdas_true, 
                    thetas=thetas_true, 
                    Q_matrix=Q_matrix, 
                    Design_array=Design_array)
itempars_true <- matrix(runif(J*2,.1,.2), ncol=2)

Y_sim <- sim_hmcdm(model="DINA",Alphas,Q_matrix,Design_array,
                   itempars=itempars_true)
                   
## rRUM ##
J = nrow(Q_matrix)
K = ncol(Q_matrix)
Smats <- matrix(runif(J*K,.1,.3),c(J,K))
Gmats <- matrix(runif(J*K,.1,.3),c(J,K))
r_stars <- Gmats / (1-Smats)
pi_stars <- apply((1-Smats)^Q_matrix, 1, prod)

Y_sim <- sim_hmcdm(model="rRUM",Alphas,Q_matrix,Design_array,
                   r_stars=r_stars,pi_stars=pi_stars)

## NIDA ##
K = ncol(Q_matrix)
Svec <- runif(K,.1,.3)
Gvec <- runif(K,.1,.3)

Y_sim <- sim_hmcdm(model="NIDA",Alphas,Q_matrix,Design_array,
                   Svec=Svec,Gvec=Gvec)
# }

Run the code above in your browser using DataLab