Learn R Programming

CDM (version 1.4-16)

sim.gdina: Simulation of the GDINA model

Description

The function sim.gdina.prepare creates necessary design matrices Mj, Aj and necc.attr. In most cases, only the list of item parameters delta must be modified by the user when applying the simulation function sim.gdina. The distribution of latent classes $\alpha$ is represented by an underlying multivariate normal distribution $\alpha^\ast$ for which a mean vector thresh.alpha and a covariance matrix cov.alpha must be specified. Alternatively, a matrix of skill classes alpha can be given as an input.

Usage

sim.gdina(n, q.matrix, delta, link = "identity", 
    thresh.alpha=NULL, cov.alpha=NULL, alpha=NULL,
    Mj, Aj, necc.attr)
sim.gdina.prepare( q.matrix )

Arguments

n
Number of persons
q.matrix
Q matrix
delta
List with $J$ entries where $J$ is the number of items. Every list element corresponds to the parameter of an item.
link
Link function. Choices are identity (default), logit and log.
thresh.alpha
Vector of thresholds (means) of $\alpha^\ast$
cov.alpha
Covariance matrix of $\alpha^\ast$
alpha
Matrix of skill classes if they should not be simulated
Mj
Design matrix, see gdina
Aj
Design matrix, see gdina
necc.attr
List with $J$ entries containing necessary attributes for each item

Value

  • The output of sim.gdina is a list with following entries:
  • dataSimulated item responses
  • alphaData frame with simulated attributes
  • q.matrixUsed Q matrix
  • deltaUsed delta item parameters
  • AjDesign matrices Aj
  • MjDesign matrices Mj
  • linkUsed link function
  • The function sim.gdina.prepare possesses the following values as output in a list: delta, necc.attr, Aj and Mj.

References

de la Torre, J. (2011) The generalized {DINA} model framework. Psychometrika, 76, 179--199.

See Also

For estimating the GDINA model see gdina.

Examples

Run this code
##############################################
# Example: Simulating the GDINA model

n <- 50             # number of persons
# define Q matrix
q.matrix <- matrix(  c(1,1,0 ,
                0,1,1,
                1,0,1,
                1,0,0,
                0,0,1,
                0,1,0,
                1,1,1,
                0,1,1,
                0,1,1) , ncol=3 , byrow=TRUE)
# thresholds for attributes alpha^\ast
thresh.alpha <- c( .65 , 0 , -.30 )
# covariance matrix for alpha^\ast
cov.alpha <- matrix(1,3,3)
cov.alpha[1,2] <- cov.alpha[2,1] <- .4
cov.alpha[1,3] <- cov.alpha[3,1] <- .6
cov.alpha[3,2] <- cov.alpha[2,3] <- .8

# prepare design matrix by applying sim.gdina.prepare function
rp <- sim.gdina.prepare( q.matrix )
delta <- rp$delta
necc.attr <- rp$necc.attr
Aj <- rp$Aj
Mj <- rp$Mj
# define delta parameters
# intercept - main effects - second order interactions - ...
str(delta)  # => modify the delta parameter list which contains only zeroes as default
##   List of 9
##    $ : num [1:4] 0 0 0 0
##    $ : num [1:4] 0 0 0 0
##    $ : num [1:4] 0 0 0 0
##    $ : num [1:2] 0 0
##    $ : num [1:2] 0 0
##    $ : num [1:2] 0 0
##    $ : num [1:8] 0 0 0 0 0 0 0 0
##    $ : num [1:4] 0 0 0 0
##    $ : num [1:4] 0 0 0 0
delta[[1]] <- c( .2 , .1 , .15 , .4 )
delta[[2]] <- c( .2 , .3 , .3 , -.2 )
delta[[3]] <- c( .2 , .2 , .2 , 0 )
delta[[4]] <- c( .15 , .6 )
delta[[5]] <- c( .1 , .7 )
delta[[6]] <- c( .25 , .65 )
delta[[7]] <- c( .25 , .1 , .1 , .1 , 0 , 0 , 0 , .25 )
delta[[8]] <- c( .2 , 0 , .3 , -.1 )
delta[[9]] <- c( .2 , .2 , 0 , .3 )

#******************************************
# Now, the "real simulation" is starting
sim.res <- sim.gdina( n=n , q.matrix =q.matrix , delta=delta , link = "identity" , 
            thresh.alpha=thresh.alpha , cov.alpha=cov.alpha ,
                Mj=Mj , Aj=Aj , necc.attr =necc.attr)
# sim.res$data      # data
# sim.res$alpha     # alpha

Run the code above in your browser using DataLab