# NOT RUN {
library(dplyr)
## generate a 100-item pool
pool <- model_3pl()$gendata(1, 100)$items
pool$content <- sample(1:3, 100, replace=TRUE)
pool$time <- round(rlnorm(100, log(60), .2))
## ex. 1: 6 forms, 10 items, maximize b parameter
x <- ata(pool, 6, len=10, maxselect=1)
x <- ata_obj_relative(x, "b", "max")
x <- ata_solve(x)
sapply(x$items, function(x) {
c(mean=mean(x$b), sd=sd(x$b), min=min(x$b), max=max(x$b))
}) %>% t() %>% round(., 2)
## ex. 2: 4 forms, 10 items, minimize b parameter
x <- ata(pool, 3, len=10, maxselect=1)
x <- ata_obj_relative(x, "b", "min", negative=TRUE)
x <- ata_solve(x, as.list=FALSE, timeout=5)
group_by(x$items, form) %>%
summarise(mean=mean(b), sd=sd(b), min=min(b), max=max(b)) %>%
round(., 2)
## ex. 3: 2 forms, 10 items, mean(b) = 0, sd(b) = 1.0, content = (3, 3, 4)
x <- ata(pool, 2, len=10, maxselect=1) %>%
ata_obj_absolute(pool$b, 0 * 10) %>%
ata_obj_absolute((pool$b - 0)^2, 1 * 10) %>%
ata_constraint("content", min=3, max=3, level=1) %>%
ata_constraint("content", min=3, max=3, level=2) %>%
ata_constraint("content", min=4, max=4, level=3)
x <- ata_solve(x, verbose="normal", timeout=5)
sapply(x$items, function(x) {
c(mean=mean(x$b), sd=sd(x$b))
}) %>% t() %>% round(., 2)
# ex. 4: 2 forms, 10 items, flat TIF over [-1, 1]
x <- ata(pool, 2, len=10, maxselect=1) %>%
ata_obj_relative(seq(-1, 1, .5), "max", flatten=0.05)
x <- ata_solve(x)
plot(x)
# }
Run the code above in your browser using DataLab