The following code block uses mirt
to define population parameters for ten 3PL IRT models. This
will be used to set up a CAT interface that can be used for on-line use (with the shiny GUI) or
off-line use (for testing or Monte Carlo simulation research).
library('mirtCAT')
## Define population parameters
a <- c(1, 1.2, 0.9, 0.8, 1.1, 1.2, 0.8, 0.7, 0.5, 1)
d <- c(-1, 1.5, 0, 0.5, -0.5, -1, 0, 0.1, 1.1, -0.2)
g <- rep(0.2, 10)
pars <- data.frame(a1 = a, d = d, g = g)
lc <- matrix(2)
## Generate mirt_object for CAT session
mirt_object <- generate.mirt_object(pars, itemtype = "3PL", latent_covariance = lc)
coef(mirt_object, simplify = TRUE)
## $items
## a1 d g u
## Item.1 1.0 -1.0 0.2 1
## Item.2 1.2 1.5 0.2 1
## Item.3 0.9 0.0 0.2 1
## Item.4 0.8 0.5 0.2 1
## Item.5 1.1 -0.5 0.2 1
## Item.6 1.2 -1.0 0.2 1
## Item.7 0.8 0.0 0.2 1
## Item.8 0.7 0.1 0.2 1
## Item.9 0.5 1.1 0.2 1
## Item.10 1.0 -0.2 0.2 1
##
## $means
## F1
## 0
##
## $cov
## F1
## F1 2
## generate random response pattern
set.seed(1)
pattern <- generate_pattern(mirt_object, Theta = 1)
print(pattern)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## [1,] 0 1 1 1 0 1 1 1 1 0
## attr(,"Theta")
## [,1]
## [1,] 1
result <- mirtCAT(mo = mirt_object, local_pattern = pattern, start_item = "MI", criteria = "MI")
print(result)
## n.items.answered Theta_1 SE.Theta_1 True.Theta_1
## 10 0.3355297 0.7412855 1
summary(result)
## $final_estimates
## Theta_1
## Estimates 0.3355297
## SEs 0.7412855
##
## $raw_responses
## [1] "1" "2" "1" "2" "2" "2" "1" "2" "2" "2"
##
## $scored_responses
## [1] 0 1 0 1 1 1 0 1 1 1
##
## $items_answered
## [1] 5 2 10 3 4 6 1 7 8 9
##
## $thetas_history
## Theta_1
## [1,] 0.00000000
## [2,] -0.54818934
## [3,] -0.26313479
## [4,] -0.59660763
## [5,] -0.31564368
## [6,] -0.13408840
## [7,] 0.20113254
## [8,] 0.00222366
## [9,] 0.16594761
## [10,] 0.28885265
## [11,] 0.33552967
##
## $thetas_SE_history
## Theta_1
## [1,] 1.4142136
## [2,] 1.1733174
## [3,] 1.0314490
## [4,] 0.9390705
## [5,] 0.8992738
## [6,] 0.8600808
## [7,] 0.8499781
## [8,] 0.8114719
## [9,] 0.7753160
## [10,] 0.7507977
## [11,] 0.7412855
##
## $true_thetas
## [1] 1
plot(result)
# score the final response vector with a different estimator
responses <- summary(result, sort = FALSE)$scored_responses
fscores(mirt_object, response.pattern = responses, method = "ML")
## Item.1 Item.2 Item.3 Item.4 Item.5 Item.6 Item.7 Item.8 Item.9
## [1,] 0 1 1 1 0 1 1 1 1
## Item.10 F1 SE_F1
## [1,] 0 0.4609681 0.8596507
This next section generates a plausible response vector given \(\theta = 1\), and passes
the response vector to mirtCAT()
for off-line use.
## generate random response pattern
set.seed(1)
pattern <- generate_pattern(mirt_object, Theta = 1)
print(pattern)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## [1,] 0 1 1 1 0 1 1 1 1 0
## attr(,"Theta")
## [,1]
## [1,] 1
# use adaptive method using maximum-information item selection
result <- mirtCAT(mo=mirt_object, local_pattern=pattern, criteria='MI', start_item = 'MI')
print(result)
## n.items.answered Theta_1 SE.Theta_1 True.Theta_1
## 10 0.3355297 0.7412855 1
summary(result)
## $final_estimates
## Theta_1
## Estimates 0.3355297
## SEs 0.7412855
##
## $raw_responses
## [1] "1" "2" "1" "2" "2" "2" "1" "2" "2" "2"
##
## $scored_responses
## [1] 0 1 0 1 1 1 0 1 1 1
##
## $items_answered
## [1] 5 2 10 3 4 6 1 7 8 9
##
## $thetas_history
## Theta_1
## [1,] 0.00000000
## [2,] -0.54818934
## [3,] -0.26313479
## [4,] -0.59660763
## [5,] -0.31564368
## [6,] -0.13408840
## [7,] 0.20113254
## [8,] 0.00222366
## [9,] 0.16594761
## [10,] 0.28885265
## [11,] 0.33552967
##
## $thetas_SE_history
## Theta_1
## [1,] 1.4142136
## [2,] 1.1733174
## [3,] 1.0314490
## [4,] 0.9390705
## [5,] 0.8992738
## [6,] 0.8600808
## [7,] 0.8499781
## [8,] 0.8114719
## [9,] 0.7753160
## [10,] 0.7507977
## [11,] 0.7412855
##
## $true_thetas
## [1] 1
plot(result)