## Dichotomous models ##
# Loading the 'tcals' parameters
data(tcals)
# Matrix of item parameters (with no content balancing)
bank <- as.matrix(tcals[,1:4])
# Creation of a starting list: 5 items, initial theta 0, bw 2
start <- list(nrItems = 5, theta = 0, halfRange = 2)
# Creation of 'test' list: weighted likelihood estimation of provisional ability,
# and MFI criterion for next item selection
test <- list(method = "WL", itemSelect = "MFI")
# Creation of 'final' list: EAP estimation of final ability
final <- list(method = "EAP")
# Creation of a stopping rule: precision criterion, standard error to be reached 0.3
stop <- list(rule = "precision", thr = 0.3)
# CAT test
res <- randomCAT(0, bank, start = start, test = test, stop = stop, final = final)
# Creation of a (purely artificial) response pattern for post-hoc simulation
resp <- rbinom(nrow(bank), 1, 0.5)
res.ph <- randomCAT(0, bank, start = start, test = test, stop = stop, final = final,
responses = resp)
# New 'test' and 'final' rules (BM and EAP estimation with Jeffreys' prior,
# randomesque value 5)
test2 <- list(method = "BM", priorDist = "Jeffreys", randomesque = 5)
final2 <- list(method = "EAP", priorDist = "Jeffreys")
# New stopping rule: classification criterion, with classification threshold 0 and
# alpha level 0.05
stop2 <- list(rule = "classification", thr = 0, alpha = 0.05)
# CAT test with new 'test', 'stop' and 'final' rules
res2 <- randomCAT(0, bank, start = start, test = test2, stop = stop2, final = final2)
# New stopping rule: classification criterion, with classification threshold 0.5
# and alpha level 0.05
stop3 <- list(rule = "classification", thr = 0.5, alpha = 0.05)
# CAT test with new 'stop' rule
res3 <- randomCAT(0, bank, start = start, test = test2, stop = stop3, final=final2)
# new 'test' and 'stop' rule for next item selection
test3 <- list(method = "WL", itemSelect = "MLWI")
stop4 <- list(rule = "length",thr = 10)
res4 <- randomCAT(0, bank, start = start, test = test3, stop = stop4, final = final2)
# Creation of the 'cbList' list with arbitrary proportions
cbList <- list(names = c("Audio1", "Audio2", "Written1", "Written2",
"Written3"), props = c(0.1, 0.2, 0.2, 0.2, 0.3))
# CAT test with 'start', 'test', 'stop4' and 'final2' lists and content balancing
# using 'cbList' ('tcals' must be used now for content balancing)
res5 <- randomCAT(0, tcals, start = start, test = test, stop = stop4, final = final2,
cbControl = cbList)
# Using progressive item selection rule and requiring all ability estimates and SEs
test4 <- list(itemSelect = "progressive")
res6 <- randomCAT(0, tcals, start = start, test = test4, stop = stop4, final = final,
cbControl = cbList, allTheta = TRUE)
# Saving the output in the external 'out' text file within folder 'Program Files'
# of hard drive 'C'
res5 <- randomCAT(0, tcals, start = start, test = test, stop = stop4, final = final2,
cbControl = cbList, save.output = TRUE,
output = c("c:/Program Files/", "out", "txt"))
# Plotting results
plot(res)
plot(res, ci = TRUE)
plot(res, ci = TRUE, trueTh = FALSE)
plot(res, ci = TRUE, classThr = 1)
# Saving last figure into PDF file 'figure' within folder 'C:/Program Files/'
plot(res, ci = TRUE, classThr = 1, save.plot = TRUE,
save.options = c("c:/Program Files/", "figure", "pdf"))
# With mistake
plot(res, ci = 0.05)
plot(res, classThr = TRUE)
## Polytomous models ##
# Generation of an item bank under GRM with 100 items and at most 4 categories
m.GRM <- genPolyMatrix(100, 4, "GRM")
m.GRM <- as.matrix(m.GRM)
# CAT options
start <- list(nrItems = 3,startSelect = "MFI")
test <- list(method = "BM", itemSelect = "KL")
stop <- list(rule = "precision", thr = 0.4)
final <- list(method = "EAP")
# CAT test
res <- randomCAT(0, m.GRM,model = "GRM", start = start, test = test, stop = stop,
final = final)
res
# Creation of an appropriate list for content balancing
# Equal proprotions across subgroups of items
cbList <- list(names = c("Group1", "Group2", "Group3", "Group4"), props = rep(1,4))
# With content balancing, all ability estimates and progressive method
m.GRM <- genPolyMatrix(100, 4, "GRM", cbControl = cbList)
test <- list(method = "BM", itemSelect = "progressive")
res <- randomCAT(0, m.GRM, model = "GRM", start = start, test = test, stop = stop,
final = final, cbControl = cbList, allTheta = TRUE)
res
# Generation of an item bank under PCM with 100 items, 4 categories and groups
m.PCM <- genPolyMatrix(100, 4, "PCM", same.nrCat = TRUE, cbControl = cbList)
stop <- list(rule = "length", thr = 10)
res <- randomCAT(0, m.PCM, model = "PCM", start = start, test = test, stop = stop,
final = final, cbControl = cbList, allTheta = TRUE)
resRun the code above in your browser using DataLab