## Not run:
# data(data.ecpe)
#
# #*** Model 1: LCDM model
# mod1 <- CDM::gdina( data.ecpe$data[,-1], q.matrix= data.ecpe$q.matrix , link="logit")
# summary(mod1)
#
# #*** Model 2: DINA model
# mod2 <- CDM::gdina( data.ecpe$data[,-1], q.matrix= data.ecpe$q.matrix , rule="DINA")
# summary(mod2)
#
# # Model comparison using likelihood ratio test
# anova(mod1,mod2)
# ## Model loglike Deviance Npars AIC BIC Chisq df p
# ## 2 Model 2 -42841.61 85683.23 63 85809.23 86185.97 206.0359 18 0
# ## 1 Model 1 -42738.60 85477.19 81 85639.19 86123.57 NA NA NA
#
# #*** Model 3: Hierarchical LCDM (HLCDM) | Templin and Bradshaw (2014)
# # Testing a linear hierarchy
# hier <- "skill3 > skill2 > skill1"
# skill.names <- colnames( data.ecpe$q.matrix )
# # define skill space with hierarchy
# skillspace <- CDM::skillspace.hierarchy( hier , skill.names= skill.names )
# skillspace$skillspace.reduced
# ## skill1 skill2 skill3
# ## A000 0 0 0
# ## A001 0 0 1
# ## A011 0 1 1
# ## A111 1 1 1
# zeroprob.skillclasses <- skillspace$zeroprob.skillclasses
#
# # define user-defined parameters in LCDM: hierarchical LCDM (HLCDM)
# Mj.user <- mod1$Mj
# # select items with require two attributes
# items <- which( rowSums( data.ecpe$q.matrix ) > 1 )
# # modify design matrix for item parameters
# for (ii in items){
# m1 <- Mj.user[[ii]]
# Mj.user[[ii]][[1]] <- (m1[[1]])[,-2]
# Mj.user[[ii]][[2]] <- (m1[[2]])[-2]
# }
#
# # estimate model
# # note that avoid.zeroprobs is set to TRUE to avoid algorithmic instabilities
# mod3 <- CDM::gdina( data.ecpe$data[,-1] , q.matrix= data.ecpe$q.matrix , link="logit" ,
# zeroprob.skillclasses=zeroprob.skillclasses , Mj=Mj.user ,
# avoid.zeroprobs=TRUE )
# summary(mod3)
#
# #*****************************************
# #** estimate further models
#
# #*** Model 4: RRUM model
# mod4 <- CDM::gdina( data.ecpe$data[,-1], q.matrix= data.ecpe$q.matrix , rule="RRUM")
# summary(mod4)
# # compare some models
# IRT.compareModels(mod1 , mod2, mod3, mod4 )
#
# #*** Model 5a: GDINA model with identity link
# mod5a <- CDM::gdina( data.ecpe$data[,-1], q.matrix= data.ecpe$q.matrix , link="identity")
# summary(mod5a)
# #*** Model 5b: GDINA model with logit link
# mod5b <- CDM::gdina( data.ecpe$data[,-1], q.matrix= data.ecpe$q.matrix , link="logit")
# summary(mod5b)
# #*** Model 5c: GDINA model with log link
# mod5c <- CDM::gdina( data.ecpe$data[,-1], q.matrix= data.ecpe$q.matrix , link="log")
# summary(mod5c)
# # compare models
# IRT.compareModels(mod5a, mod5b, mod5c)
# ## End(Not run)
Run the code above in your browser using DataLab