philchalmers / mirt

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

unable to find an inherited method for function ‘Deriv’ for signature with (Q)MCEM methods #111

Closed seonghobae closed 7 years ago

seonghobae commented 7 years ago

Hi Phil,

I met these messages when I try ty estimate standard error in my model with (Q)MCEM methods.

# QMCEM models were converged, but unable to find an inherited method for function ‘Deriv’.
> mirt(Science, 1, method = 'QMCEM', SE = T) # polytomous
Iteration: 44, Log-Lik: -1608.916, Max-Change: 0.00009
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘Deriv’ for signature ‘"graded", "NULL"’

> mirt(expand.table(LSAT7), 1, method = 'QMCEM', SE = T) # polytomous
Iteration: 28, Log-Lik: -2658.807, Max-Change: 0.00010
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘Deriv’ for signature ‘"dich", "NULL"’
# MCEM models were converged?
> mirt(Science, 1, method = 'MCEM', SE = T) # polytomous
Iteration: 500, Log-Lik: -1609.300, Max-Change: 0.07573
EM cycles terminated after 500 iterations.
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘Deriv’ for signature ‘"graded", "NULL"’

> mirt(expand.table(LSAT7), 1, method = 'MCEM', SE = T) # dichotomous
Iteration: 500, Log-Lik: -2659.582, Max-Change: 0.04628
EM cycles terminated after 500 iterations.
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘Deriv’ for signature ‘"dich", "NULL"’

Here is my work environment informations.

Seongho

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949    LC_MONETARY=Korean_Korea.949 LC_NUMERIC=C                 LC_TIME=Korean_Korea.949    

attached base packages:
[1] grid      stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] psych_1.7.5           semTools_0.4-14       lavaan_0.6-1.1137     GPArotation_2014.11-1 TAM_2.3-18            CDM_5.7-16            mvtnorm_1.0-6        
 [8] car_2.1-4             rsm_2.8               pracma_2.0.7          psychometric_2.2      rmeta_2.16            metafor_2.0-0         Matrix_1.2-10        
[15] meta_4.8-2            lsr_0.5               multilevel_2.6        nlme_3.1-131          plyr_1.8.4            latticeExtra_0.6-28   RColorBrewer_1.1-2   
[22] mirt_1.24.3           lattice_0.20-35       bfa_0.4               rrcovNA_0.4-9         rrcov_1.4-3           robustbase_0.92-7     SQUAREM_2016.8-2     
[29] stringr_1.2.0         depmixS4_1.3-3        Rsolnp_1.16           MASS_7.3-47           nnet_7.3-12           RevoUtilsMath_10.0.0 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.11       zoo_1.8-0          truncnorm_1.0-7    MatrixModels_0.4-1 pcaPP_1.9-72       coda_0.19-1        lsmeans_2.26-3     multcomp_1.4-6    
 [9] minqa_1.2.4        SparseM_1.77       norm_1.0-9.5       nloptr_1.0.4       WrightMap_1.2.1    pbivnorm_0.6.0     splines_3.4.0      RevoUtils_10.0.4  
[17] lme4_1.1-13        foreign_0.8-69     compiler_3.4.0     mnormt_1.5-5       mgcv_1.8-17        polycor_0.7-9      quadprog_1.5-5     codetools_0.2-15  
[25] xtable_1.8-2       magrittr_1.5       estimability_1.2   stringi_1.1.5      sandwich_2.3-4     TH.data_1.0-8      tools_3.4.0        DEoptimR_1.0-8    
[33] sfsmisc_1.1-1      parallel_3.4.0     pbkrtest_0.4-7     survival_2.41-3    cluster_2.0.6      quantreg_5.33     
philchalmers commented 7 years ago

Patched. Also note: Monte Carlo EM algorithms never really "converge", unless the stochastic draws are extremely large. Best just to treat those as approximations.

seonghobae commented 7 years ago
# tried to another condition after patch 76fbaf4
> mirt(expand.table(LSAT7), 1, method = 'MCEM', SE = T, SE.type = 'central')
Iteration: 500, Log-Lik: -2659.691, Max-Change: 0.04392
EM cycles terminated after 500 iterations.

Calculating information matrix...
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),  : 
  'data' must be of a vector type, was 'NULL'
> mirt(expand.table(LSAT7), 1, method = 'QMCEM', SE = T, SE.type = 'central')
Iteration: 28, Log-Lik: -2658.807, Max-Change: 0.00010

Calculating information matrix...
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),  : 
  'data' must be of a vector type, was 'NULL'
> 
> mirt(expand.table(LSAT7), 1, method = 'MCEM', SE = T, SE.type = 'crossprod')
Iteration: 500, Log-Lik: -2658.875, Max-Change: 0.01416
EM cycles terminated after 500 iterations.

Calculating information matrix...
Error in computeItemtrace(pars = pars[[g]], Theta = Theta, itemloc = itemloc,  : 
  Not compatible with requested type: [type=NULL; target=double].
> mirt(expand.table(LSAT7), 1, method = 'QMCEM', SE = T, SE.type = 'crossprod')
Iteration: 28, Log-Lik: -2658.807, Max-Change: 0.00010

Calculating information matrix...
Error in computeItemtrace(pars = pars[[g]], Theta = Theta, itemloc = itemloc,  : 
  Not compatible with requested type: [type=NULL; target=double].
> 
> mirt(expand.table(LSAT7), 1, method = 'MCEM', SE = T, SE.type = 'sandwich')
Iteration: 500, Log-Lik: -2658.822, Max-Change: 0.01721
EM cycles terminated after 500 iterations.

Calculating information matrix...
Error in computeItemtrace(pars = pars[[g]], Theta = Theta, itemloc = itemloc,  : 
  Not compatible with requested type: [type=NULL; target=double].
> mirt(expand.table(LSAT7), 1, method = 'QMCEM', SE = T, SE.type = 'sandwich')
Iteration: 28, Log-Lik: -2658.807, Max-Change: 0.00010

Calculating information matrix...
Error in computeItemtrace(pars = pars[[g]], Theta = Theta, itemloc = itemloc,  : 
  Not compatible with requested type: [type=NULL; target=double].
> 
> mirt(expand.table(LSAT7), 1, method = 'MCEM', SE = T, SE.type = 'Fisher')
Iteration: 500, Log-Lik: -2658.859, Max-Change: 0.01054
EM cycles terminated after 500 iterations.

Calculating information matrix...
Error in computeItemtrace(pars = pars, Theta = Theta, itemloc = itemloc,  : 
  Not compatible with requested type: [type=NULL; target=double].
> mirt(expand.table(LSAT7), 1, method = 'QMCEM', SE = T, SE.type = 'Fisher')
Iteration: 28, Log-Lik: -2658.807, Max-Change: 0.00010

Calculating information matrix...
Error in computeItemtrace(pars = pars, Theta = Theta, itemloc = itemloc,  : 
  Not compatible with requested type: [type=NULL; target=double].
> 
> mirt(expand.table(LSAT7), 1, method = 'MCEM', SE = T, SE.type = 'complete')
Iteration: 500, Log-Lik: -2658.831, Max-Change: 0.00739
EM cycles terminated after 500 iterations.

Calculating information matrix...

Call:
mirt(data = expand.table(LSAT7), model = 1, SE = T, SE.type = "complete", 
    method = "MCEM")

Full-information item factor analysis with 1 factor(s).
FAILED TO CONVERGE within 1e-04 tolerance after 500 MCEM iterations.
mirt version: 1.24.3 
M-step optimizer: BFGS 
Number of Monte Carlo points: 1498

Log-likelihood = -2658.831
Estimated parameters: 10 
AIC = 5337.663; AICc = 5337.885
BIC = 5386.74; SABIC = 5354.98
G2 (21) = 31.75, p = 0.062
RMSEA = 0.023, CFI = 0.939, TLI = 0.924
> mirt(expand.table(LSAT7), 1, method = 'QMCEM', SE = T, SE.type = 'complete')
Iteration: 28, Log-Lik: -2658.807, Max-Change: 0.00010

Calculating information matrix...

Call:
mirt(data = expand.table(LSAT7), model = 1, SE = T, SE.type = "complete", 
    method = "QMCEM")

Full-information item factor analysis with 1 factor(s).
Converged within 1e-04 tolerance after 28 QMCEM iterations.
mirt version: 1.24.3 
M-step optimizer: BFGS 
EM acceleration: Ramsay 
Number of quasi-Monte Carlo points: 5000

Information matrix estimated with method: complete
Condition number of information matrix = 5.364449
Second-order test: model is a possible local maximum

Log-likelihood = -2658.807
Estimated parameters: 10 
AIC = 5337.614; AICc = 5337.836
BIC = 5386.691; SABIC = 5354.931
G2 (21) = 31.7, p = 0.0627
RMSEA = 0.023, CFI = 0.939, TLI = 0.924
philchalmers commented 7 years ago

Thanks for the test cases. Behaviour should be better now.