philchalmers / mirt

Multidimensional item response theory
https://philchalmers.github.io/mirt/
199 stars 75 forks source link

itemGAM error #160

Closed aivelo closed 5 years ago

aivelo commented 5 years ago

I am exploring the use of mirt and IRTs in general for the first time and analyzing a dataset of multidimensional (5 dimensions) Likert-scale data. My model seems to have good overall fit, based on RMSEA and CFI, but item fits are quite poor (more than half of my 20 items, have fit < 0.01). I am trying to use itemGAM to figure out why the fit is poor, but this results in cryptic error:

Error in .C(C_pls_fit1, y = as.double(z), X = as.double(x[good, ]), w = as.double(w), : Incorrect number of arguments (12), expecting 14 for 'pls_fit1'

I did quickly build a reproducible example which leads to same error:

set.seed(1234)
model <- mirt.model('
                    F1 = 1,2,3,4,5
                    F2 = 6,7,8,9,10
                    F3 = 11,12,13,14,15
                    COV = F1*F2*F3')

a1 <- rlnorm(5, .2, .2)
a2 <- rlnorm(5,-.2,.2)
a3 <- rlnorm(5,0,.2)

diffs <- t(apply(matrix(runif(15*5, .3, 1), 15), 1, cumsum))
diffs <- -(diffs - rowMeans(diffs))
d <- diffs + rnorm(15)

likert <- simdata(c(a1,a2,a3), d, 500, 'gpcm')

mod_gpcm <- mirt(likert, model, itemtype="gpcm", method="MHRM")
Theta <- fscores(mod_gpcm)
test <- itemGAM(likert[,2], Theta)
philchalmers commented 5 years ago

I can't reproduce this on the dev version. I get the following:

> test <- itemGAM(likert[,2], Theta)
return.models is always set to TRUE for multidimensional models
> test
$cat_1

Family: binomial 
Link function: logit 

Formula:
resp ~ s(Theta, k = 10)

Estimated degrees of freedom:
1  total = 2 

UBRE score: -0.2585748     

$cat_2

Family: binomial 
Link function: logit 

Formula:
resp ~ s(Theta, k = 10)

Estimated degrees of freedom:
4.39  total = 5.39 

UBRE score: -0.3289043     

$cat_3

Family: binomial 
Link function: logit 

Formula:
resp ~ s(Theta, k = 10)

Estimated degrees of freedom:
2.82  total = 3.82 

UBRE score: -0.4127393     

$cat_4

Family: binomial 
Link function: logit 

Formula:
resp ~ s(Theta, k = 10)

Estimated degrees of freedom:
2.96  total = 3.96 

UBRE score: -0.4248931     

$cat_5

Family: binomial 
Link function: logit 

Formula:
resp ~ s(Theta, k = 10)

Estimated degrees of freedom:
1  total = 2 

UBRE score: -0.5486963    

In which case things like plot(test[[1]]) works as expected. Can you install the dev version to see if this is reproducible on your end? I'll close this for now but feel free to re-open if the problem persists.