Implement ConQuest score command in TAM

孤者浪人 提交于 2019-12-02 09:33:46

I didn't get an answer here, but I contacted Alexander Robitzsch, the author of the TAM package, and here's what he send me (published with his permission):

data(data.gpcm)
psych::describe(data.gpcm)
resp <- data.gpcm

# define three dimensions and different loadings
# of item categories on these dimensions
I <- 3  # 3 items
D <- 3  # 3 dimensions

# define loading matrix B
# 4 categories for each item (0,1,2,3)
B <- array( 0 , dim=c(I,4,D) )
for (ii in 1:I){
    B[ ii , 1:4  , 1 ] <- 0:3
    B[ ii , 1 ,2 ] <- 1
    B[ ii , 4 ,3 ] <- 1
            }
dimnames(B)[[1]] <- colnames(resp)
B[1,,]
  ##   > B[1,,]
  ##        [,1] [,2] [,3]
  ##   [1,]    0    1    0
  ##   [2,]    1    0    0
  ##   [3,]    2    0    0
  ##   [4,]    3    0    1

# test run
mod1 <- tam.mml( resp , B = B , control=list( snodes=1000 , maxiter=5)  )
summary(mod1)

I had to edit the code for my needs, of course, but something in particular might be of interest for all of you: For some reason, the B matrix only worked if I had also defined a 0 category, although my ratings/data only included values from 1 to 5:

B <- array( 0 , dim=c(9,6,5) ) # 9 items, 5 response cat. + 1, 5 latent dimensions
for (ii in 1:I){
  B[ ii , 1:6  , 1 ] <- 0:5
  B[ ii , 2 ,2 ] <- 1
  B[ ii , 2 ,3 ] <- 1
  B[ ii , 6 ,3 ] <- 1
  B[ ii , 6 ,4 ] <- 1
  B[ ii , 4 ,5 ] <- 1
}

dimnames(B)[[1]] <- colnames(X)
B[1,,]

Cheers, KH

Just as an extension to the above answer with TAM, here is how to run the same code with the mirt package, except using the generalized partial credit model instead of the Rasch model (Rasch model requires an explicit model argument for proper identification).

library(mirt)
gpcm_mats <- list(B[1,,], B[2,,], B[3,,])
sv <- mirt(resp, 3, itemtype = 'gpcm', 
           gpcm_mats = gpcm_mats, pars = 'values') #starting values
mod <- mirt(resp, 3, itemtype = 'gpcm', gpcm_mats = gpcm_mats)
coef(mod, simplify=TRUE)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!