if (FALSE) {
##################
#
# data simulation
#
##################
set.seed(123)
msQ <- matrix(
c(1,1,0,1,
1,2,1,0,
2,1,1,0,
3,1,0,1,
4,1,1,1,
5,1,1,1),6,4,byrow = T)
# J x L - 00,10,01,11
LC.prob <- matrix(c(
0.2,0.7727,0.5889,0.8125,
0.1,0.9,0.1,0.9,
0.1,0.1,0.8,0.8,
0.2,0.5,0.4,0.7,
0.2,0.4,0.7,0.9),5,4,byrow=TRUE)
N <- 10000
att <- sample(1:4,N,replace=TRUE)
dat <- 1*(t(LC.prob[,att])>matrix(runif(N*5),N,5))
est <- GMSCDM(dat,msQ)
# item response function
est$IRF
# strategy specific IRF
est$sIRF
################################
#
# Example 14 from GDINA function
#
################################
Q <- matrix(c(1,1,1,1,0,
1,2,0,1,1,
2,1,1,0,0,
3,1,0,1,0,
4,1,0,0,1,
5,1,1,0,0,
5,2,0,0,1),ncol = 5,byrow = TRUE)
d <- list(
item1=c(0.2,0.7),
item2=c(0.1,0.6),
item3=c(0.2,0.6),
item4=c(0.2,0.7),
item5=c(0.1,0.8))
set.seed(123)
sim <- simGDINA(N=1000,Q = Q, delta.parm = d,
model = c("MSDINA","MSDINA","DINA",
"DINA","DINA","MSDINA","MSDINA"))
# simulated data
dat <- extract(sim,what = "dat")
# estimation
# MSDINA need to be specified for each strategy
est <- GDINA(dat,Q,model = c("MSDINA","MSDINA","DINA",
"DINA","DINA","MSDINA","MSDINA"),
control = list(conv.type = "neg2LL",conv.crit = .01))
# Approximate the MS-DINA model using GMS DINA model
est2 <- GMSCDM(dat, Q, model = "rDINA", s = 10,
control = list(conv.type = "neg2LL",conv.crit = .01))
}
Run the code above in your browser using DataLab