11.8 Replicating the process: An example
One sample is usually referred to as one replication in a simulation study. To minimize the sampling error, we usually replicate the same analysis multiple times and average the PCV across all replications.
Code
set.seed(123)
library(GDINA)
Rep <- 30
PCA <- PCV <- matrix(NA, Rep, 3)
for (r in 1:Rep) {
gs <- matrix(runif(J * 2, 0.2, 0.45), ncol = 2)
sim <- simGDINA(N = N, Q = Q15, gs.parm = gs, model = "DINA", att.dist = "uniform")
Y <- GDINA::extract(sim, what = "dat")
true.attributes <- GDINA::extract(sim, what = "attribute")
est <- GDINA(Y, Q15, model = "DINA", verbose = 0)
MLE <- personparm(est, what = "MLE")
MAP <- personparm(est, what = "MAP")
EAP <- personparm(est, what = "EAP")
PCA[r, ] <- c(ClassRate(EAP, true.attributes)$PCA, ClassRate(MLE[,
1:K], true.attributes)$PCA, ClassRate(MAP[, 1:K], true.attributes)$PCA)
PCV[r, ] <- c(ClassRate(EAP, true.attributes)$PCV[K], ClassRate(MLE[,
1:K], true.attributes)$PCV[K], ClassRate(MAP[, 1:K], true.attributes)$PCV[K])
}
colMeans(PCA)
## [1] 0.6151 0.6133 0.6052
## [1] 0.1177 0.1203 0.1123