Skip to content

Commit 5df35d5

Browse files
committed
fix placeholders
1 parent e5bfdeb commit 5df35d5

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

R/mirt.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,9 @@ mirt <- function(data, model = 1, itemtype = NULL, guess = 0, upper = 1, SE = FA
14461446
has_idesign <- colnames(data) %in% rownames(itemdesign)
14471447
if(!any(has_idesign))
14481448
stop('No rownames in itemdesign match colnames(data)', call.=FALSE)
1449+
dummy <- as.data.frame(matrix(NA, sum(!has_idesign), ncol(itemdesign)))
1450+
colnames(dummy) <- colnames(itemdesign)
1451+
itemdesign <- rbind(dummy, itemdesign)
14491452
} else {
14501453
has_idesign <- rep(TRUE, nrow(itemdesign))
14511454
rownames(itemdesign) <- colnames(data)
@@ -1471,7 +1474,7 @@ mirt <- function(data, model = 1, itemtype = NULL, guess = 0, upper = 1, SE = FA
14711474
colnames(mm[[i]]) <- paste0(names(mm)[i], '.', colnames(mm[[i]]))
14721475
mm <- do.call(cbind, mm)
14731476
} else {
1474-
mf <- model.frame(item.formula, itemdesign)
1477+
mf <- model.frame(item.formula, itemdesign, na.action = NULL)
14751478
mm <- model.matrix(item.formula, mf)
14761479
}
14771480

tests/testthat/test-18-LLTM.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ test_that('MLTM', {
6161
itemdesign <- data.frame(t1_difficulty= factor(d1, labels=c('medium', 'easy')),
6262
t2_difficulty=factor(d2, labels=c('hard', 'medium', 'easy')))
6363
rownames(itemdesign) <- colnames(dat)[19:30]
64-
itemdesign
6564

6665
# fit MLTM design, leaving first 18 items as 'Rasch' type
6766
mltm <- mirt(dat, syntax, itemtype=itemtype, itemdesign=itemdesign,
@@ -98,10 +97,10 @@ test_that('MLTM', {
9897
t2_difficulty=factor(c(rep(NA, 18), d2), labels=c('hard', 'medium', 'easy')),
9998
difficulty=factor(c(d, rep(NA, 12)), labels=c('hard', 'medium', 'easy')))
10099

101-
mixed <- mirt(dat, syntax, itemtype=itemtype, itemdesign=itemdesign,
102-
item.formula = list(theta1 ~ 0 + t1_difficulty,
103-
theta2 ~ 0 + t2_difficulty,
104-
~ difficulty), SE=TRUE, verbose=FALSE)
100+
# mixed <- mirt(dat, syntax, itemtype=itemtype, itemdesign=itemdesign,
101+
# item.formula = list(theta1 ~ 0 + t1_difficulty,
102+
# theta2 ~ 0 + t2_difficulty,
103+
# ~ difficulty), SE=TRUE, verbose=FALSE)
105104

106105

107106
})

0 commit comments

Comments
 (0)