|
| 1 | +context('LLTM') |
| 2 | + |
| 3 | +test_that('LLTM', { |
| 4 | + set.seed(42) |
| 5 | + a <- matrix(rep(1,30)) |
| 6 | + d <- rep(c(1,0, -1),each = 10) # first easy, then medium, last difficult |
| 7 | + dat <- simdata(a, d, 1000, itemtype = '2PL') |
| 8 | + itemdesign <- data.frame(difficulty = |
| 9 | + factor(c(rep('easy', 10), rep('medium', 10), rep('hard', 10)))) |
| 10 | + rownames(itemdesign) <- colnames(dat) |
| 11 | + |
| 12 | + lltm <- mirt(dat, itemtype = 'Rasch', SE=TRUE, verbose=FALSE, |
| 13 | + item.formula = ~ 0 + difficulty, itemdesign=itemdesign) |
| 14 | + expect_equal(as.numeric(coef(lltm, simplify=TRUE)$items[1:2,1]), c(0.9587247, 0.9587247), tol=1e-2) |
| 15 | + expect_equal(as.numeric(coef(lltm, printSE=TRUE)[[1]][2, 1:3]), c(0.03886556, 0.03898911, 0.03769205), tol=1e-2) |
| 16 | + expect_equal(extract.mirt(lltm, 'condnum'), 6.633144, tol=1e-2) |
| 17 | + |
| 18 | + # additional information for LLTM |
| 19 | + oo <- plot(lltm) |
| 20 | + expect_is(oo, 'trellis') |
| 21 | + ifit <- itemfit(lltm) |
| 22 | + expect_equal(ifit$S_X2[1:3], c(20.06072, 20.90161, 23.48163), tol=1e-2) |
| 23 | + eap <- fscores(lltm) |
| 24 | + expect_equal(eap[1:3], c(1.0141828, -0.2427042, -0.2427042)) |
| 25 | + |
| 26 | + # using unconditional modeling for first four items |
| 27 | + itemdesign.sub <- itemdesign[5:nrow(itemdesign), , drop=FALSE] |
| 28 | + lltm.4 <- mirt(dat, itemtype = 'Rasch', SE=TRUE, verbose=FALSE, |
| 29 | + item.formula = ~ 0 + difficulty, itemdesign=itemdesign.sub) |
| 30 | + cfs <- coef(lltm.4, simplify=TRUE)$items |
| 31 | + expect_equal(as.vector(cfs[c(1,5), 1:3]), c(0, .9063842, numeric(4)), tol=1e-2) |
| 32 | + expect_equal(anova(lltm, lltm.4)$p[2], 0.04288353, tol=1e-2) |
| 33 | + |
| 34 | +}) |
| 35 | + |
| 36 | +test_that('MLTM', { |
| 37 | + |
| 38 | +}) |
| 39 | + |
0 commit comments