Simulation of the GDINA model

Share:

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 α is represented by an underlying multivariate normal distribution α^\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.

Note that this version of sim.gdina only works for dichotomous attributes.

Usage

1
2
3
4
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 (see sim.din)

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 α^\ast

cov.alpha

Covariance matrix of α^\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:

data

Simulated item responses

alpha

Data frame with simulated attributes

q.matrix

Used Q-matrix

delta

Used delta item parameters

Aj

Design matrices A_j

Mj

Design matrices M_j

link

Used 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

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#############################################################################
# EXAMPLE 1: 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" starts
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      # simulated data
# sim.res$alpha     # simulated alpha

## Not run: 
#############################################################################
# EXAMPLE 2: Simulation based on already estimated GDINA model for data.ecpe
#############################################################################

data(data.ecpe)
dat <- data.ecpe$data
q.matrix <- data.ecpe$q.matrix

#***
# (1) estimate GDINA model
mod <- gdina( data=dat[,-1] , q.matrix=q.matrix )

#***
# (2) simulate data according to GDINA model
set.seed(977)

# prepare design matrix by applying sim.gdina.prepare function
rp <- sim.gdina.prepare( q.matrix )
necc.attr <- rp$necc.attr

# number of subjects to be simulated
n <- 3000
# simulate attribute patterns
probs <- mod$attribute.patt$class.prob   # probabilities
patt <- mod$attribute.patt.splitted      # response patterns
alpha <- patt[ sample( 1:(length(probs) ) , n , prob=probs , replace=TRUE) , ]

# simulate data using estimated item parameters
sim.res <- sim.gdina( n=n, q.matrix =q.matrix, delta=mod$delta, link = "identity", 
                alpha=alpha , Mj=mod$Mj , Aj= mod$Aj , necc.attr = rp$necc.attr)               
# extract data
dat <- sim.res$data

#############################################################################
# EXAMPLE 3: Simulation based on already estimated RRUM model for data.ecpe
#############################################################################

data(data.ecpe)
dat <- data.ecpe$data
q.matrix <- data.ecpe$q.matrix

#***
# (1) estimate reduced RUM model
mod <- gdina( data=dat[,-1] , q.matrix=q.matrix , rule="RRUM" )
summary(mod)

#***
# (2) simulate data according to RRUM model
set.seed(977)

# prepare design matrix by applying sim.gdina.prepare function
rp <- sim.gdina.prepare( q.matrix )
necc.attr <- rp$necc.attr

# number of subjects to be simulated
n <- 5000
# simulate attribute patterns
probs <- mod$attribute.patt$class.prob   # probabilities
patt <- mod$attribute.patt.splitted      # response patterns
alpha <- patt[ sample( 1:(length(probs) ) , n , prob=probs , replace=TRUE) , ]

# simulate data using estimated item parameters
sim.res <- sim.gdina( n=n, q.matrix =q.matrix, delta=mod$delta, link = mod$link , 
                alpha=alpha , Mj=mod$Mj , Aj=mod$Aj , necc.attr = rp$necc.attr)               
# extract data
dat <- sim.res$data

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.