Introduction We present a package for the analysis of (non-hierarchical) Multinomial Processing Tree (MPT) models for the statistical programming language R: MPTinR. MPTinR combines two approaches, extending the functionality of other software for MPTs: ease of use and amount of functionalities. The homepage of MPTinR (including documentation) is: Introduction We present a package for the analysis of (non-hierarchical) Multinomial Processing Tree (MPT) models for the statistical programming language R: MPTinR. MPTinR combines two approaches, extending the functionality of other software for MPTs: ease of use and amount of functionalities. The homepage of MPTinR (including documentation) is: Features The advantages of MPTinR over similar programs for fitting MPTs are: MPTinR is an R package and therefore integrates smoothly with a R-workflow. MPTinR is free software and open source! MPTinR allows an easy and intuitive way to specify the model in a file that even allows comments (via “#”). Furthermore, MPTinR supports the 'classical' EQN syntax (as GPT, HMMTree, MultiTree). Sequential equality and inequality model restrictions can be specified in an external file. MPTinR provides different outputs for individual and datasets consisting of multiple individuals. In the latter case, results for each individual, sums of the individual results, and results from aggregating the data are automatically provided. For model selection, the Fisher information approximation (FIA), a minimum description length based measure of model complexity, can be obtained using the algorithm provided by Wu, Myung and Batchelder (2010). For multiple individuals or multiple fitting runs the package allows one to easily use multiple cores (or CPUs) via the snowfall package by simply specifying the number of available cores. Features The advantages of MPTinR over similar programs for fitting MPTs are: MPTinR is an R package and therefore integrates smoothly with a R-workflow. MPTinR is free software and open source! MPTinR allows an easy and intuitive way to specify the model in a file that even allows comments (via “#”). Furthermore, MPTinR supports the 'classical' EQN syntax (as GPT, HMMTree, MultiTree). Sequential equality and inequality model restrictions can be specified in an external file. MPTinR provides different outputs for individual and datasets consisting of multiple individuals. In the latter case, results for each individual, sums of the individual results, and results from aggregating the data are automatically provided. For model selection, the Fisher information approximation (FIA), a minimum description length based measure of model complexity, can be obtained using the algorithm provided by Wu, Myung and Batchelder (2010). For multiple individuals or multiple fitting runs the package allows one to easily use multiple cores (or CPUs) via the snowfall package by simply specifying the number of available cores. Installation MPTinR is hosted on R-Forge: To install simply type at an R prompt: install.packages("MPTinR", repos=" Forge.R-project.org") Installation MPTinR is hosted on R-Forge: To install simply type at an R prompt: install.packages("MPTinR", repos=" Forge.R-project.org") * Contact: * Contact: Model Files MPTinR allows two ways two specify the model file: 1.The new “easy” format 2.The classical EQN format. Furthermore, MPTinR can create EQN model files from models specified in the “easy” format via the function make.eqn(). Next, we compare model files for the sample 2HTM model (on the right) for both formats: Model Files MPTinR allows two ways two specify the model file: 1.The new “easy” format 2.The classical EQN format. Furthermore, MPTinR can create EQN model files from models specified in the “easy” format via the function make.eqn(). Next, we compare model files for the sample 2HTM model (on the right) for both formats: Easy FormatEQN Format Trees are separated by at least one empty line. Model files can contain comments (via “#”) Needs a special syntax (see e.g., Stahl & Klauer, 2007) This file was constructed using make.eqn() #Tree for old items Do + (1 - Do) * g (1-Do)*(1-g) #Tree for new items (1-Dn) * g Dn + (1-Dn) * (1 - g) Do 1 1 (1-Do)*g 1 2 (1-Do)*(1-g) 2 4 Dn 2 3 (1-Dn)*g 2 4 (1-Dn)*(1-g) MPTinR allows two ways two specify the model file: Restrictions Files Model restrictions can be specified in an external file. MPTinR allows for sequential equality (“=“) and inequality (“<“) restrictions. Restriction files can contain comments (“#”) Models are reparametrized to accommodate the restrictions (using “method A”; Knapp & Batchelder, 2004). Restrictions Files Model restrictions can be specified in an external file. MPTinR allows for sequential equality (“=“) and inequality (“<“) restrictions. Restriction files can contain comments (“#”) Models are reparametrized to accommodate the restrictions (using “method A”; Knapp & Batchelder, 2004). # Example: #Ds are ordered D1 < D2 < D3 #D4 equal to D2 D4 = D2 # Bs set to.33 B1 = B3 = X4 = X5 = G6 Fitting Algorithm Fitting is done by the general purpose optimization routine L-BFGS-B (Byrd et al., 1995), a quasi-Newton (i.e., gradient-based) method. Multiple fitting runs (with random starting values) can be initiated to avoid local minima. Alternatively, starting values can be specified. Currently other algorithms (e.g., simplex) are being implemented. Fitting Algorithm Fitting is done by the general purpose optimization routine L-BFGS-B (Byrd et al., 1995), a quasi-Newton (i.e., gradient-based) method. Multiple fitting runs (with random starting values) can be initiated to avoid local minima. Alternatively, starting values can be specified. Currently other algorithms (e.g., simplex) are being implemented. Example: Model Fitting Fitting the 2HTM to the data from Bröder & Schütz (2009, Exp. 3) : > fit.mpt(d.broeder, m.2htm, fia = ) $goodness.of.fit Log.Likelihood G.Squared df p.value $information.criteria FIA AIC BIC $model.info rank.hessian n.parameters n.independent.categories $parameters estimates lower.conf upper.conf Dn Do G G G G G $data $data$observed [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] [...] $data$predicted [,1] [,2] [,3] [,4] [,5] [1,] [...] For individual data the output would contain the single elements (e.g., goodness.of.fit, parameters ) for the individual data, the sum of the individual data, and the aggregated data. Example: Model Fitting Fitting the 2HTM to the data from Bröder & Schütz (2009, Exp. 3) : > fit.mpt(d.broeder, m.2htm, fia = ) $goodness.of.fit Log.Likelihood G.Squared df p.value $information.criteria FIA AIC BIC $model.info rank.hessian n.parameters n.independent.categories $parameters estimates lower.conf upper.conf Dn Do G G G G G $data $data$observed [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] [...] $data$predicted [,1] [,2] [,3] [,4] [,5] [1,] [...] For individual data the output would contain the single elements (e.g., goodness.of.fit, parameters ) for the individual data, the sum of the individual data, and the aggregated data. Fisher Information Approximation The Fisher Information Approximation (FIA) is a minimum description length based measure of model complexity. The FIA measures complexity not only by the number of parameters (as do AIC and BIC) but estimates the functional form of the model. MPTinR can compute the FIA for any MPT using the MCMC algorithm by Wu, Myung and Batchelder (2010) ported to R. To this end MPTinR first transforms the model into the context free language of MPT Models (L-BMPT; Purdy & Batchelder, 2009). The example 2HTM (see section “Model Files”) in L-BMPT is: hj1 Do 1 g 1 2 Dn 4 g 3 4 (numbers refer to response categories, the parameter hj1 joins both trees into a single tree) Fisher Information Approximation The Fisher Information Approximation (FIA) is a minimum description length based measure of model complexity. The FIA measures complexity not only by the number of parameters (as do AIC and BIC) but estimates the functional form of the model. MPTinR can compute the FIA for any MPT using the MCMC algorithm by Wu, Myung and Batchelder (2010) ported to R. To this end MPTinR first transforms the model into the context free language of MPT Models (L-BMPT; Purdy & Batchelder, 2009). The example 2HTM (see section “Model Files”) in L-BMPT is: hj1 Do 1 g 1 2 Dn 4 g 3 4 (numbers refer to response categories, the parameter hj1 joins both trees into a single tree) Future Developments Parametric/Nonparametric Bootstrap and Jackknife methods Latent Class hierarchical modeling Normalized Maximum Likelihood approximation Increase Computing Performance Future Developments Parametric/Nonparametric Bootstrap and Jackknife methods Latent Class hierarchical modeling Normalized Maximum Likelihood approximation Increase Computing Performance References Bröder, A., & Schütz, J. (2009). Recognition ROCs are curvilinear—or are they? On premature arguments against the two-high-threshold model of recognition. Journal of Experimental Psychology: Learning, Memory, and Cognition, 35(3), 587. Byrd, R. H., Lu, P., Nocedal, J., & Zhu, C. (1995). A limited memory algorithm for bound constrained optimization. SIAM J. Scientific Computing, 16, Knapp, B. R., & Batchelder, W. H. (2004). Representing parametric order constraints in multi- trial applications of multinomial processing tree models. Journal of Mathematical Psychology, 48, Purdy, B. P., & Batchelder, W. H. (2009). A context-free language for binary multinomial processing tree models. Journal of Mathematical Psychology, 53, Stahl, C., & Klauer, K. C. (2007). HMMTree: A computer program for latent-class hierarchical multinomial processing tree models. Behavior Research Methods, 39, 267–273. Wu, H., Myung, J.I., & Batchelder, W.H. (2010). Minimum description length model selection of multinomial processing tree models. Psychonomic Bulletin & Review, 17, References Bröder, A., & Schütz, J. (2009). Recognition ROCs are curvilinear—or are they? On premature arguments against the two-high-threshold model of recognition. Journal of Experimental Psychology: Learning, Memory, and Cognition, 35(3), 587. Byrd, R. H., Lu, P., Nocedal, J., & Zhu, C. (1995). A limited memory algorithm for bound constrained optimization. SIAM J. Scientific Computing, 16, Knapp, B. R., & Batchelder, W. H. (2004). Representing parametric order constraints in multi- trial applications of multinomial processing tree models. Journal of Mathematical Psychology, 48, Purdy, B. P., & Batchelder, W. H. (2009). A context-free language for binary multinomial processing tree models. Journal of Mathematical Psychology, 53, Stahl, C., & Klauer, K. C. (2007). HMMTree: A computer program for latent-class hierarchical multinomial processing tree models. Behavior Research Methods, 39, 267–273. Wu, H., Myung, J.I., & Batchelder, W.H. (2010). Minimum description length model selection of multinomial processing tree models. Psychonomic Bulletin & Review, 17, Example: Model Selection Output of the model selection function comparing the fits of 40 individual data sets from Bröder & Schütz (2009, Exp. 3) to the original 2HTM, a restricted 2HTM (Do = Dn), and a 1HTM (Dn = 0). select.mpt() takes the outputs from fit.mpt() and creates the following table: > select.mpt(list(orig.2htm = br.2htm, res.2htm = br.2htm.res, orig.1htm = br.1htm)) model n.parameters delta.FIA.sum FIA.best delta.AIC.sum wAIC.sum AIC.best delta.BIC.sum wBIC.sum BIC.best 1 orig.2htm res.2htm orig.1htm Example: Model Selection Output of the model selection function comparing the fits of 40 individual data sets from Bröder & Schütz (2009, Exp. 3) to the original 2HTM, a restricted 2HTM (Do = Dn), and a 1HTM (Dn = 0). select.mpt() takes the outputs from fit.mpt() and creates the following table: > select.mpt(list(orig.2htm = br.2htm, res.2htm = br.2htm.res, orig.1htm = br.1htm)) model n.parameters delta.FIA.sum FIA.best delta.AIC.sum wAIC.sum AIC.best delta.BIC.sum wBIC.sum BIC.best 1 orig.2htm res.2htm orig.1htm Poster presented at the 44th Annual Meeting of the Society for Mathematical Psychology, Boston, Massachusetts, July 2011 MPTinR: An (almost) complete R package for analyzing Multinomial Processing Tree Models Henrik Singmann*, David Kellen, Fabian Hölzenbein, & Christoph Klauer University of Freiburg