Unidimensional Example

This example demonstrates how a unidimensional IRT test can be scored and modified for off-line and on-line use.

The following code-block defines 100 items for a math test measuring addition skills.

library('mirtCAT')
options(stringsAsFactors = FALSE)

# define population IRT parameters
set.seed(1234)
nitems <- 100
itemnames <- paste0('Item.', 1:nitems)
a <- matrix(rlnorm(nitems, .2, .3))
d <- matrix(rnorm(nitems))
pars <- data.frame(a1=a, d=d, g=0.2)
mod <- generate.mirt_object(pars, '3PL')

# math items definitions
# addition for one factor and multiplication for the other
questions <- answers <- character(nitems)
choices <- matrix('a', nitems, 5)
spacing <- floor(d - min(d)) + 1 #easier items have more variation

for(i in 1:nitems){
    n1 <- sample(1:100, 1)
    n2 <- sample(101:200, 1)
    ans <- n1 + n2
    questions[i] <- paste0(n1, ' + ', n2, ' = ?')
    answers[i] <- as.character(ans)
    ch <- ans + sample(c(-5:-1, 1:5) * spacing[i,], 5)
    ch[sample(1:5, 1)] <- ans
    choices[i,] <- as.character(ch)
}

df <- data.frame(Questions=questions, Answer=answers, Option=choices, Type='radio')
head(df)
##      Questions Answer Option.1 Option.2 Option.3 Option.4 Option.5  Type
## 1 69 + 142 = ?    211      211      219      207      195      231 radio
## 2 63 + 142 = ?    205      214      220      205      193      208 radio
## 3 52 + 178 = ?    230      230      224      233      236      221 radio
## 4 94 + 120 = ?    214      199      208      205      214      226 radio
## 5 44 + 194 = ?    238      229      241      238      244      235 radio
## 6 82 + 189 = ?    271      283      267      291      271      275 radio

Check how test is expected to behave given its overall information criteria.

plot(mod)

plot of chunk unnamed-chunk-2

#test appears to measure theta with SE < .4 within -2 to 2 range
plot(mod, type = 'infoSE', theta_lim=c(-3,3))

plot of chunk unnamed-chunk-2

Run the GUI using maximum-information selection, EAP estimation, random starting item, and stopping when \(SE(\hat{\theta}) < 0.5\).

result <- mirtCAT(df, mod, method = 'EAP', criteria = 'MI', start_item = 'random',
                  design = list(min_SEM = 0.5))
print(result)
plot(result)
summary(result)