Dear Phil, thanks for mitt package and for being always so supportive with questions here.
I`m facing a challenge to model the ability of the same students measured in 3 time-points. I've read and did all the steps from
https://philchalmers.github.io/mirt/html/Longitudinal-IRT.html but I was unable to adapt the code for my results. Because of that, I gently ask for your help (if it`s possible).
I have a Likert-type questionnaire with 6 items that can be replied with 0,1 or 2 and it was used during 3 years in a row with the same participants. This questionnaire is unidimensional.
Below it's what I did.
head(data) #item 1-6 was from 1st year, 7-12 was from 2nd year and 13-18 the third year
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18
1 2 2 2 1 2 2 2 2 1 2 2 1 2 2 0 2 2 2
2 2 2 2 2 2 2 2 2 2 0 2 2 2 2 2 2 2 2
3 1 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2
4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
5 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2
6 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
model <- mirt.model('Intercept = 1-18
Slope = 1-18
COV = Intercept*Slope, Intercept*Intercept, Slope*Slope
MEAN = Intercept, Slope') #as you can see, I modified the syntax because I have only 6 items, 3 times (18)
itemloadings <- rep(1:6, times = 3) #same thing here. 6 items, 3 times
sv <- bfactor(dat, itemloadings, model, pars='values')
sv$value[sv$name == 'a1'] <- 1
sv$est[sv$name == 'a1'] <- FALSE
sv$value[sv$name == 'a2'] <- rep(0:2, each=6)
sv$est[sv$name == 'a2'] <- FALSE
#I˜m sorry, but I could not understand this block but I've preserved
# create constraint list
constraints <- list()
itemnames <- colnames(dat)
pick <- c(0,6,12) #I modified because I have 6 items
for(i in 1:6){
# accross time item constraints
constraints[[paste0('slope.', i)]] <- sv$parnum[sv$name == paste0('a',2+i) & sv$est]
for(j in 1:2){
constraints[[paste0('intercept.', i, '_', j)]] <-
sv$parnum[sv$name == paste0('d',j) & (sv$item %in% itemnames[pick + i]) & sv$est]
}
}
mod2 <- bfactor(dat, itemloadings, model, constrain=constraints, quadpts=9, pars=sv,
optimizer = 'nlminb')
coef(mod2, simplify=TRUE)
coef(mod2)$GroupPars[,c('MEAN_1', 'MEAN_2', 'COV_11', 'COV_21', 'COV_22')]
#save scores
scores_com <- data.frame(fscores(mod2))
F1 F2 F3 F4 F5 F6 F7 F8
1 1.297257e-15 2.266489e-15 -2.352151e-28 6.485141e-22 -4.713927e-13 -2.898849e-08 1.651152e-17 -1.561585e-19
2 1.683215e-07 1.024281e-12 -1.720596e-22 7.279179e-22 5.765951e-14 -5.446999e-08 1.651151e-17 7.403599e-19
3 -3.582314e-10 7.792545e-10 1.455839e-21 6.485094e-22 5.765951e-14 -2.898849e-08 1.651168e-17 -1.561585e-19
4 7.642004e-05 4.196115e-10 -1.191132e-22 6.882208e-22 5.765878e-14 7.185317e-08 1.651131e-17 7.403069e-19
5 2.107903e-07 1.257415e-12 -1.852903e-22 6.485126e-22 5.765951e-14 -2.898850e-08 1.651160e-17 7.403599e-19
I was waiting for a table with only 3 columns (year 1, year 2, year 3).
Thanks a lot for always helping us.