if (FALSE) {
#############################################################################
# EXAMPLE 1: DIF for DINA simulated data
#############################################################################
# simulate some data
set.seed(976)
N <- 2000 # number of persons in a group
I <- 9 # number of items
q.matrix <- matrix( 0, 9,2 )
q.matrix[1:3,1] <- 1
q.matrix[4:6,2] <- 1
q.matrix[7:9,c(1,2)] <- 1
# simulate first group
guess <- rep( .2, I )
slip <- rep(.1, I)
dat1 <- CDM::sim.din( N=N, q.matrix=q.matrix, guess=guess, slip=slip,
mean=c(0,0) )$dat
# simulate second group with some DIF items (items 1, 7 and 8)
guess[ c(1,7)] <- c(.3, .35 )
slip[8] <- .25
dat2 <- CDM::sim.din( N=N, q.matrix=q.matrix, guess=guess, slip=slip,
mean=c(0.4,.25) )$dat
group <- rep(1:2, each=N )
dat <- rbind( dat1, dat2 )
#*** estimate multiple group GDINA model
mod1 <- CDM::gdina( dat, q.matrix=q.matrix, rule="DINA", group=group )
summary(mod1)
#*** assess differential item functioning
dmod1 <- CDM::gdina.dif( mod1)
summary(dmod1)
## item X2 df p p.holm UA
## 1 I001 10.1711 2 0.0062 0.0495 0.0428
## 2 I002 1.9933 2 0.3691 1.0000 0.0276
## 3 I003 0.0313 2 0.9845 1.0000 0.0040
## 4 I004 0.0290 2 0.9856 1.0000 0.0044
## 5 I005 2.3230 2 0.3130 1.0000 0.0142
## 6 I006 1.8330 2 0.3999 1.0000 0.0159
## 7 I007 40.6851 2 0.0000 0.0000 0.1184
## 8 I008 6.7912 2 0.0335 0.2346 0.0710
## 9 I009 1.1538 2 0.5616 1.0000 0.0180
}
Run the code above in your browser using DataLab