library(mirt)
library(TestGardener)
# dataGenerationModel is a WfdList or mirt object
# R is iteration, theta is true scores with length of sample size
# dataGenerationModelType is list of models and config for each model. Can be optimal, graded och gpcm
# modelsToCompare is a vector with combinations of optimal and/or (graded or gpcm)
# thetas is a (sequence) vector of index values to fit models in each iteration
# optScr is list of score options, required when fitting optimal scores models
simulate <- function(R, dataGenerationModel, thetas,
dataGenerationModelType="optimal",
modelsToCompare=list(c("gpcm", "EAP"), c("gpcm", "ML"), c("optimal", cycles=15)),
optScr=NULL,
usePrecalibrated=F,
preCalibratedOptimal=NULL,
preCalibratedParMod=NULL) {
n <- length(thetas)
res <- matrix(NA, nrow = 0, ncol = n+1)
for (r in 1:R) {
resMat <- simulationIteration(r, n, dataGenerationModel, thetas,
dataGenerationModelType,
modelsToCompare,
optScr,
usePrecalibrated,
preCalibratedOptimal,
preCalibratedParMod)
res <- rbind(res, resMat)
}
return(list(truethetas = thetas, simRes = res))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.