## Not run:
# #############################################################################
# # EXAMPLE 1: Dataset G308 from Schroeders et al. (2014)
# #############################################################################
#
# data(data.g308)
# dat <- data.g308
#
# library(TAM)
# library(sirt)
# library(combinat)
#
# # define testlets
# testlet <- c(1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 5, 5, 6, 6, 6)
#
# #****************************************
# #*** Model 1: Rasch model
# mod1 <- TAM::tam.mml(resp = dat[,-1], pid = dat[,1],
# control = list(maxiter = 300 , snodes = 1500))
# summary(mod1)
#
# #****************************************
# #*** Model 2: Rasch testlet model
#
# # testlets are dimensions, assign items to Q-matrix
# TT <- length(unique(testlet))
# Q <- matrix(0, nrow = ncol(dat)-1 , ncol = TT + 1)
# Q[,1] <- 1 # First dimension constitutes g-factor
# for (tt in 1:TT){Q[testlet == tt, tt+1] <- 1}
#
# # In a testlet model, all dimensions are uncorrelated among
# # each other, that is, all pairwise correlations are set to 0,
# # which can be accomplished with the "variance.fixed" command
# variance.fixed <- cbind(t( combinat::combn(TT+1,2)), 0)
# mod2 <- TAM::tam.mml(resp = dat[,-1], pid = dat[,1], Q = Q,
# variance.fixed = variance.fixed,
# control = list(snodes = 1500 , maxiter = 300))
# summary(mod2)
#
# #****************************************
# #*** Model 3: Partial credit model
#
# scores <- list()
# testlet.names <- NULL
# dat.pcm <- NULL
# for (tt in 1:max(testlet) ){
# scores[[tt]] <- rowSums (dat[,-1][, testlet == tt, drop = FALSE])
# dat.pcm <- c(dat.pcm, list(c(scores[[tt]])))
# testlet.names <- append(testlet.names, paste0("testlet",tt) )
# }
# dat.pcm <- as.data.frame(dat.pcm)
# colnames(dat.pcm) <- testlet.names
# mod3 <- TAM::tam.mml(resp = dat.pcm, control = list(snodes=1500, maxiter=300) )
# summary(mod3)
#
# #****************************************
# #*** Model 4: Copula model
#
# mod4 <- sirt::rasch.copula2 (dat = dat[,-1], itemcluster = testlet)
# summary(mod4)
# ## End(Not run)
Run the code above in your browser using DataLab