alexanderrobitzsch / TAM

Test Analysis Modules
https://alexanderrobitzsch.github.io/TAM/
15 stars 9 forks source link

Is Quasi-Monte Carlo integration not possible with tam.mml.3pl()? #1

Closed hplieninger closed 7 years ago

hplieninger commented 7 years ago

I tried to fit models using tam.mml.3pl() with Quasi-Monte Carlo integration (e.g., control = list(snodes = 1000), but that is either not possible or there is a bug.

I am referring to the examples in tam.mml.3pl(): In example mod1 and mod6, I get the error Error in matrix(1, nrow = nstud, ncol = ntheta) : object 'ntheta' not found. In example mod9, I don't get an error, but the snodes are ignored and numerical integration is used.

This applies to both TAM 2.7-56 and the current GitHub version 2.8-4.

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

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

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

other attached packages:
[1] TAM_2.7-56    CDM_5.9-27    mvtnorm_1.0-6 magrittr_1.5 

loaded via a namespace (and not attached):
[1] compiler_3.4.1  tools_3.4.1     coda_0.19-1     yaml_2.1.14    
[5] Rcpp_0.12.13    grid_3.4.1      polycor_0.7-9   lattice_0.20-35
[9] sfsmisc_1.1-1  
alexanderrobitzsch commented 7 years ago

Am 24.10.2017 um 15:47 schrieb hplieninger:

I tried to fit models using tam.mml.3pl() with Quasi-Monte Carlo integration (e.g., control = list(snodes = 1000), but that is either not possible or there is a bug.

Probably I had to be more careful in sending warning messages because Quasi Monte Carlo (QMC) is not implemented for tam.mml.3pl. The reason is that the computation is done on a number classes and item parameters are formulated as functions of latent class parameters as restricted latent class models (see the Formann papers). The multivariate normal distribution can be reformulated as log-linear smoothing of class probabilities. For example in a two-dimensional model, using

nodes <- seq(-4,4,len=15) theta <- expand.grid( nodes, nodes)

specifies a two-dimensional grid. A bivariate normal distribution has moments

theta[,1]^2, theta[,2]^2, and theta[,1]*theta[,2]

which can be used as columns in the design matrix for class probabilities.

I usually create QMC nodes by using sfsmisc::QUnif and applying some transformation from [0,1]^2 to (-\infty, \infty)^2. These transformed nodes can be simply included as "theta" values for located latent classes in tam.mml.3pl.

Surely, this is not very convenient, but possible.

Alexander

I am referring to the examples in tam.mml.3pl(): In example mod1 and mod6, I get the error Error in matrix(1, nrow = nstud, ncol = ntheta) : object 'ntheta' not found. In example mod9, I don't get an error, but the snodes are ignored and numerical integration is used.

This applies to both TAM 2.7-56 and the current GitHub version 2.8-4.

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

Matrix products: default

locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 [4] LC_NUMERIC=C LC_TIME=German_Germany.1252

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

other attached packages: [1] TAM_2.7-56 CDM_5.9-27 mvtnorm_1.0-6 magrittr_1.5

loaded via a namespace (and not attached): [1] compiler_3.4.1 tools_3.4.1 coda_0.19-1 yaml_2.1.14 Rcpp_0.12.13 grid_3.4.1 polycor_0.7-9 [8] lattice_0.20-35 sfsmisc_1.1-1

--

...........................................

Alexander Robitzsch IPN - Leibniz-Institut für die Pädagogik der Naturwissenschaften und Mathematik an der Universität Kiel Olshausenstraße 62, D-24098 Kiel Tel.: +49 (0)431 880-3487, Fax: -5211 E-Mail: robitzsch@ipn.uni-kiel.de Raum: Olshausenstraße 62, Raum 37

https://sites.google.com/site/alexanderrobitzsch http://www.ipn.uni-kiel.de/de

...........................................

alexanderrobitzsch commented 7 years ago

Am 24.10.2017 um 15:47 schrieb hplieninger:

I tried to fit models using tam.mml.3pl() with Quasi-Monte Carlo integration (e.g., control = list(snodes = 1000), but that is either not possible or there is a bug.

I am referring to the examples in tam.mml.3pl(): In example mod1 and mod6, I get the error Error in matrix(1, nrow = nstud, ncol = ntheta) : object 'ntheta' not found. In example mod9, I don't get an error, but the snodes are ignored and numerical integration is used.

By chance, I received yesterday the same bug report by a user which reminded my that the stochastic nodes could be used in TAM::tam.mml.3pl in version 1.9999-31. Hence, I unintentionally disbled the functionality when I restructered the function which happened in more recent TAM versions. The bug fix should be in TAM 2.8-8 at

https://github.com/alexanderrobitzsch/TAM

Alexander

This applies to both TAM 2.7-56 and the current GitHub version 2.8-4.

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

Matrix products: default

locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 [4] LC_NUMERIC=C LC_TIME=German_Germany.1252

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

other attached packages: [1] TAM_2.7-56 CDM_5.9-27 mvtnorm_1.0-6 magrittr_1.5

loaded via a namespace (and not attached): [1] compiler_3.4.1 tools_3.4.1 coda_0.19-1 yaml_2.1.14 Rcpp_0.12.13 grid_3.4.1 polycor_0.7-9 [8] lattice_0.20-35 sfsmisc_1.1-1