philchalmers / mirt

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

fixed NA values in upper triangular part of cov matrix #164

Closed sebastianueckert closed 5 years ago

sebastianueckert commented 5 years ago

For a multidimensional model fit coef(fit, simplify = T) returned a matrix with NA value in the upper triangular part. This also lead to an error when simulating from a multidimensional model using simdata(model=fit). This pull request fixes these problems.

philchalmers commented 5 years ago

Thanks. Could you provide an example or this behaviour so that I can compare before/after? Also, please change all instances of F to FALSE (I believe this is required for the R CMD check --as-cran test.

sebastianueckert commented 5 years ago

Yes, sure.

mod <- mirt(Science, 2)  
coef(mod, simplify = TRUE)

Before:

$items
            a1    a2    d1    d2     d3
Comfort -1.335 0.097 5.211 2.866 -1.603
Work    -0.879 1.853 3.704 1.153 -2.904
Future  -1.470 1.165 4.663 1.957 -1.736
Benefit -1.722 0.000 3.989 1.195 -2.044

$means
F1 F2 
 0  0 

$cov
   F1 F2
F1  1 NA
F2  0  1

After:

$items
            a1    a2    d1    d2     d3
Comfort -1.335 0.097 5.211 2.866 -1.603
Work    -0.879 1.853 3.704 1.153 -2.904
Future  -1.470 1.165 4.663 1.957 -1.736
Benefit -1.722 0.000 3.989 1.195 -2.044

$means
F1 F2 
 0  0 

$cov
   F1 F2
F1  1  0
F2  0  1
philchalmers commented 5 years ago

Merged, thanks for the contribution!