sim.din
can be used to simulate dichotomous response data according to a CDM
model. The model type DINA or DINO can be specified item wise. The number of items,
the sample size, and two parameters for each item, the slipping and guessing errors,
can be set explicitly.sim.din(N=0, q.matrix, guess = rep(0.2, nrow(q.matrix)),
slip = guess, mean = rep(0, ncol(q.matrix)), Sigma =
diag(ncol(q.matrix)), rule = "DINA",alpha=NULL)
alpha
is specified, then N
is set
by default to 0.ncol(q.matrix)
indicating
the mean vector of the continuous version of the dichotomous skill vector.
Default is rep(0, length = ncol(q.matrix))
.
That is, having a probability of ncol(q.matrix)
times ncol(q.matrix)
specifying the covariance matrix of the continuous version of the dichotomous skill
vector (i.e., the tetrachoric correlation of the dichotomous skill vector)"DINA"
or "DINO"
. If a vector of character strings is
specified, implying an italpha
is not NULL
,
then mean
and Sigma
are ignored.Data-sim
for artificial date set simulated with the help of this
method; plot.din
, the S3 method for plotting objects of
the class din
; summary.din
, the S3
method for summarizing objects of the class din
, which
creates objects of the class summary.din
;
print.summary.din
, the S3 method for printing
objects of the class summary.din
; din
,
the main function for DINA and DINO parameter estimation,
which creates objects of the class din
. See also
CDM-package
for general information about this package.## simulate DINA and DINO data according to a tetrachoric correlation
# define Q-matrix for 4 items and 2 attributes
q.matrix <- matrix(c(1,0,0,1,1,1,1,1), ncol = 2, nrow = 4)
# Slipping parameters
slip <- c(0.2,0.3,0.4,0.3)
# Guessing parameters
guess <- c(0,0.1,0.05,0.2)
set.seed(1567) # fix random numbers
dat1 <- sim.din(N = 200, q.matrix, slip, guess,
# Possession of the attributes with high probability
mean = c(0.5,0.2),
# Possession of the attributes is weakly correlated
Sigma = matrix(c(1,0.2,0.2,1), ncol=2), rule = "DINA")$dat
head(dat1)
set.seed(15367) # fix random numbers
res <- sim.din(N = 200, q.matrix, slip, guess, mean =
c(0.5,0.2), Sigma = matrix(c(1,0.2,0.2,1), ncol=2),
rule = "DINO")
# extract simulated data
dat2 <- res$dat
# extract attribute patterns
head( res$alpha )
## [,1] [,2]
## [1,] 1 1
## [2,] 1 1
## [3,] 1 1
## [4,] 1 1
## [5,] 1 1
## [6,] 1 0
# simulate data based on given attributes
# -> 5 persons with 2 attributes -> see the Q matrix above
alpha <- matrix( c(1,0,1,0,1,1,0,1,1,1) ,
nrow=5,ncol=2, byrow=TRUE )
sim.din( q.matrix = q.matrix , alpha = alpha )
Run the code above in your browser using DataLab