# NOT RUN {
## Dichotomous models ##
# Loading the 'tcals' parameters
data(tcals)
# Selecting item parameters only
tcals <- as.matrix(tcals[,1:4])
# Creation of a response pattern (tcals item parameters, true ability level 0)
x <- genPattern(0, tcals, seed = 1)
# ML estimation
th <- thetaEst(tcals, x, method = "ML")
c(th, semTheta(th, tcals, method = "ML"))
# ML estimation, new ASE formula (=> yields the same result)
c(th, semTheta(th, tcals, method = "ML", sem.type = "new"))
# With first two responses missing
x.mis <- x
x.mis[1:2] <- NA
th <- thetaEst(tcals, x.mis, method = "ML")
c(th, semTheta(th, tcals, x.mis, method = "ML"))
# BM estimation, standard normal prior distribution
th <- thetaEst(tcals, x)
c(th, semTheta(th, tcals))
# BM estimation and new ASE formula
c(th, semTheta(th, tcals, sem.type = "new"))
# BM estimation, uniform prior distribution upon range [-2,2]
th <- thetaEst(tcals, x, method = "BM", priorDist = "unif",
priorPar = c(-2, 2))
c(th, semTheta(th, tcals, method = "BM", priorDist = "unif",
priorPar = c(-2, 2)))
# BM estimation, Jeffreys' prior distribution
th <- thetaEst(tcals, x, method = "BM", priorDist = "Jeffreys")
c(th, semTheta(th, tcals, method = "BM", priorDist = "Jeffreys"))
# EAP estimation, standard normal prior distribution
th <- thetaEst(tcals, x, method = "EAP")
c(th, semTheta(th, tcals, x, method = "EAP"))
# }
# NOT RUN {
# EAP estimation, uniform prior distribution upon range [-2,2]
th <- thetaEst(tcals, x, method = "EAP", priorDist = "unif",
priorPar = c(-2, 2))
c(th, semTheta(th, tcals, x, method = "EAP", priorDist = "unif",
priorPar = c(-2, 2)))
# EAP estimation, Jeffreys' prior distribution
th <- thetaEst(tcals, x, method = "EAP", priorDist = "Jeffreys")
c(th, semTheta(th, tcals, x, method = "EAP", priorDist = "Jeffreys"))
# WL estimation
th <- thetaEst(tcals, x, method = "WL")
c(th, semTheta(th, tcals, method = "WL"))
# WL estimation, new ASE formula
c(th, semTheta(th, tcals, method = "WL", sem.type = "new"))
# 'fixed4' adjustment for constant pattern
th <- thetaEst(tcals, rep(0, nrow(tcals)), constantPatt = "fixed4")
c(th, semTheta(th, tcals, constantPatt = "fixed4"))
# Robust estimation
th <- thetaEst(tcals, x, method = "ROB")
c(th, semTheta(th, tcals, method = "ROB"))
# Robust estimation, Huber weight and tuning constant 2
th <- thetaEst(tcals, x, method = "ROB", tuCo = 2)
c(th, semTheta(th, tcals, method = "ROB", tuCo = 2))
# Robust estimation, Tukey weight and tuning constant 4
th <- thetaEst(tcals, x, method = "ROB", weight = "Tukey", tuCo = 4)
c(th, semTheta(th, tcals, method = "ROB", weight = "Tukey", tuCo = 4))
## Exact SE computation under 1PL model:
# Creation of a 1PL item bank with difficulties from 'tcals' (85 items)
tcals2 <- cbind(1, tcals[, 2], 0, 1)
# Pattern generation for true ability level 1
x2 <- genPattern(1, tcals2, seed = 1)
# ML estimation
th2 <- thetaEst(tcals2, x2, method = "ML")
c(th2, semTheta(th2, tcals2, x2, method = "ML", sem.exact = TRUE))
# ML estimation, true SE in addition
c(th2, semTheta(th2, tcals2, x2, method = "ML", sem.exact = TRUE, trueTh = 1))
## Exact SE computation under 2PL model:
# Creation of a 2PL item bank with ten items
it <- genDichoMatrix(10, model = "2PL", seed = 1)
# Pattern generation for true ability level 1
x3 <- genPattern(1, it, seed = 1)
# ML estimation
th3 <- thetaEst(it, x3, method = "ML")
c(th3, semTheta(th3, it, x3, method = "ML", sem.exact = TRUE))
# ML estimation, true SE in addition
c(th3, semTheta(th3, it, x3, method = "ML", sem.exact = TRUE, trueTh = 1))
# }
# NOT RUN {
## 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)
# Creation of a response pattern (true ability level 0)
set.seed(1)
x <- genPattern(0, m.GRM, model = "GRM")
# ML estimation
th <- thetaEst(m.GRM, x, model = "GRM", method = "ML")
c(th, semTheta(th, m.GRM, model = "GRM", method = "ML"))
# BM estimation, standard normal prior distribution
th <- thetaEst(m.GRM, x, model = "GRM")
c(th, semTheta(th, m.GRM, model = "GRM"))
# BM estimation, uniform prior distribution upon range [-2,2]
th <- thetaEst(m.GRM, x, model = "GRM", method = "BM", priorDist = "unif",
priorPar = c(-2, 2))
c(th, semTheta(th, m.GRM, model = "GRM", method = "BM", priorDist = "unif",
priorPar = c(-2, 2)))
# BM estimation, Jeffreys' prior distribution
th <- thetaEst(m.GRM, x, model = "GRM", method = "BM", priorDist = "Jeffreys")
c(th, semTheta(th, m.GRM, model = "GRM", method = "BM", priorDist = "Jeffreys"))
# EAP estimation, standard normal prior distribution
th <- thetaEst(m.GRM, x, model = "GRM", method = "EAP")
c(th, semTheta(th, m.GRM, x, model = "GRM", method = "EAP") )
# }
# NOT RUN {
# EAP estimation, uniform prior distribution upon range [-2,2]
th <- thetaEst(m.GRM, x, model = "GRM", method = "EAP", priorDist = "unif",
priorPar = c(-2, 2))
c(th, semTheta(th, m.GRM, x, model = "GRM", method = "EAP", priorDist = "unif",
priorPar = c(-2, 2)))
# EAP estimation, Jeffreys' prior distribution
th <- thetaEst(m.GRM, x, model = "GRM", method = "EAP", priorDist = "Jeffreys")
c(th, semTheta(th, m.GRM, x, model = "GRM", method = "EAP", priorDist = "Jeffreys"))
# WL estimation
th <- thetaEst(m.GRM, x, model = "GRM", method = "WL")
c(th, semTheta(th, m.GRM, model = "GRM", method = "WL"))
# Loading the cat_pav data
data(cat_pav)
cat_pav <- as.matrix(cat_pav)
# Creation of a response pattern (true ability level 0)
set.seed(1)
x <- genPattern(0, cat_pav, model = "GPCM")
# ML estimation
th <- thetaEst(cat_pav, x, model = "GPCM", method = "ML")
c(th, semTheta(th, cat_pav, model = "GPCM", method = "ML"))
# BM estimation, standard normal prior distribution
th <- thetaEst(cat_pav, x, model = "GPCM")
c(th, semTheta(th, cat_pav, model = "GPCM"))
# BM estimation, uniform prior distribution upon range [-2,2]
th <- thetaEst(cat_pav, x, model = "GPCM", method = "BM", priorDist = "unif",
priorPar = c(-2, 2))
c(th, semTheta(th, cat_pav, model = "GPCM", method = "BM", priorDist = "unif",
priorPar = c(-2, 2)))
# BM estimation, Jeffreys' prior distribution
th <- thetaEst(cat_pav, x, model = "GPCM", method = "BM", priorDist = "Jeffreys")
c(th, semTheta(th, cat_pav, model = "GPCM", method = "BM", priorDist = "Jeffreys"))
# EAP estimation, standard normal prior distribution
th <- thetaEst(cat_pav, x, model = "GPCM", method = "EAP")
c(th, semTheta(th, cat_pav, x, model = "GPCM", method = "EAP"))
# EAP estimation, uniform prior distribution upon range [-2,2]
th <- thetaEst(cat_pav, x, model = "GPCM", method = "EAP", priorDist = "unif",
priorPar = c(-2, 2))
c(th, semTheta(th, cat_pav, x, model = "GPCM", method = "EAP", priorDist = "unif",
priorPar = c(-2, 2)))
# EAP estimation, Jeffreys' prior distribution
th <- thetaEst(cat_pav, x, model = "GPCM", method = "EAP", priorDist = "Jeffreys")
c(th, semTheta(th, cat_pav, x, model = "GPCM", method = "EAP", priorDist = "Jeffreys"))
# WL estimation
th <- thetaEst(cat_pav, x, model = "GPCM", method = "WL")
c(th, semTheta(th, cat_pav, model = "GPCM", method = "WL"))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab