11.9 An example: replicating the procedure a specified number of times
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)
<- 30
Rep <- PCV <- matrix(NA, Rep, 3)
PCA for (r in 1:Rep) {
<- matrix(runif(J * 2, 0.2, 0.45), ncol = 2)
gs <- simGDINA(N = N, Q = Q15, gs.parm = gs, model = "DINA", att.dist = "uniform")
sim <- GDINA::extract(sim, what = "dat")
Y <- GDINA::extract(sim, what = "attribute")
true.attributes <- GDINA(Y, Q15, model = "DINA", verbose = 0)
est <- personparm(est, what = "MLE")
MLE <- personparm(est, what = "MAP")
MAP <- personparm(est, what = "EAP")
EAP <- c(ClassRate(EAP, true.attributes)$PCA, ClassRate(MLE[,
PCA[r, ] 1:K], true.attributes)$PCA, ClassRate(MAP[, 1:K], true.attributes)$PCA)
<- c(ClassRate(EAP, true.attributes)$PCV[K], ClassRate(MLE[,
PCV[r, ] 1:K], true.attributes)$PCV[K], ClassRate(MAP[, 1:K], true.attributes)$PCV[K])
}colMeans(PCA)
## [1] 0.62 0.61 0.61
Code
colMeans(PCV)
## [1] 0.12 0.12 0.11