if (FALSE) {
# interactively through the console (not run)
#model <- mirt.model()
# F1 = 1,2,3,4-10
# F2 = 10-20
# (F1*F2) = 1,2,3,4-10
# COV = F1*F2
# Or alternatively with a string input
s <- 'F1 = 1,2,3,4-10
F2 = 10-20
(F1*F2) = 1,2,3,4-10
COV = F1*F2'
model <- mirt.model(s)
# strings can also be passed to the estimation functions directly,
# which silently calls mirt.model(). E.g., using the string above:
# mod <- mirt(data, s)
# Q-matrix specification
Q <- matrix(c(1,1,1,0,0,0,0,0,0,1,1,1), ncol=2, dimnames = list(NULL, c('Factor1', 'Factor2')))
COV <- matrix(c(FALSE, TRUE, TRUE, FALSE), 2)
model <- mirt.model(Q, COV=COV)
## constrain various items slopes and all intercepts in single group model to be equal,
# and use a log-normal prior for all the slopes
s <- 'F = 1-10
CONSTRAIN = (1-3, 5, 6, a1), (1-10, d)
PRIOR = (1-10, a1, lnorm, .2, .2)'
model <- mirt.model(s)
## constrain various items slopes and intercepts across groups for use in multipleGroup(),
# and constrain first two slopes within 'group1' to be equal
s <- 'F = 1-10
CONSTRAIN = (1-2, a1)
CONSTRAINB = (1-3, 5, 6, a1), (1-10, d)'
model <- mirt.model(s)
## specify model using raw item names
data(data.read, package = 'sirt')
dat <- data.read
# syntax with variable names
mirtsyn2 <- "
F1 = A1,B2,B3,C4
F2 = A1-A4,C2,C4
MEAN = F1
COV = F1*F1, F1*F2
CONSTRAIN=(A2-A4,a2),(A3,C2,d)
PRIOR = (C3,A2-A4,a2,lnorm, .2, .2),(B3,d,norm,0,.0001)"
# create a mirt model
mirtmodel <- mirt.model(mirtsyn2, itemnames=dat)
# or equivalently:
# mirtmodel <- mirt.model(mirtsyn2, itemnames=colnames(dat))
# mod <- mirt(dat , mirtmodel)
# using sprintf() to functionally fill in information (useful for long tests
# or more complex specifications)
nitems <- 100
s <- sprintf('F = 1-%i
CONSTRAIN = (%s, a1)
CONSTRAINB = (%s, a1), (1-%i, d)',
nitems, "1,2,4,50,100",
paste0(1:45, collapse=','),
nitems)
cat(s)
model <- mirt.model(s)
}
Run the code above in your browser using DataLab