Analyze Multinomial Processing Tree Models

Provides a user-friendly way for the analysis of multinomial processing tree (MPT) models (e.g., Riefer, D. M., and Batchelder, W. H. [1988]. Multinomial modeling and the measurement of cognitive processes. Psychological Review, 95, 318-339) for single and multiple datasets. The main functions perform model fitting and model selection. Model selection can be done using AIC, BIC, or the Fisher Information Approximation (FIA) a measure based on the Minimum Description Length (MDL) framework. The model and restrictions can be specified in external files or within an R script in an intuitive syntax or using the context-free language for MPTs. The 'classical' .EQN file format for model files is also supported. Besides MPTs, this package can fit a wide variety of other cognitive models such as SDT models (see fit.model). It also supports multicore fitting and FIA calculation (using the snowfall package), can generate or bootstrap data for simulations, and plot predicted versus observed data.


                ** MPTinR VERSION 1.10.x **
                Changes in MPTinR Version 1.10.x
                Released July 2015

Significant User Visible Changes and new Features

o   added 850 ROCs used in the meta-analysis of Klauer and Kellen (2015), 
    see ?roc6.


o   The changes made to the FIA calculation for summed data in version 1.7 
    were incorrect. FIA for multiple data sets simply needs to be summed to
    correspond to FIA when these data sets were fitted in a super-model 
    (with separate parameters for each data set). Consequently, the old 
    behavior of simply summing FIA was restored in both fit.mpt et al. and
    select.mpt. Vignette was updated to show this.

o   all functions from default packages imported.

o   FIA for first data set was sometimes incorrectly treated
    as different from get.mpt.fia (or fit.mpt).

                ** MPTinR VERSION 1.9.x **
                Changes in MPTinR Version 1.8.x
                Released June 2015

Significant User Visible Changes and new Features

o   added updated version of the MPTinR paper as vignette.

o   removed URL (site was not updated anymore).


o   select.mpt was still giving wrong FIA values for multiple data 
    sets (used G^2 instead of 0.5*G^2).

o   the summed FIA value in the output from fit.mpt and the like was
    also incorrect (also used G^2 instead of 0.5*G^2)

                ** MPTinR VERSION 1.8.x **
                Changes in MPTinR Version 1.8.x
                Released April 2015

Significant User Visible Changes and new Features



o   bug that prevented inequalities to be correctly taken into 
    account for calculation of FIA is corrected (Thanks to 
    Christoph Klauer for noticing this). This bug was introduced in 
    version 1.6.

o   prepare.mpt.fia was not working, fixed.

                ** MPTinR VERSION 1.7.x **
                Changes in MPTinR Version 1.7.x
                Released March 2015

Significant User Visible Changes and new Features

o   less messages if show.messages == FALSE.


o   summed BIC and FIA values were calculated incorrectly (i.e., 
    the individual values were simply summed which is incorrect due
    to the non-linear nature of the log(n) term). This is now
    corrected for both the output of fit.mpt (et al.) and 
    select.mpt (for which now summed BIC and FIA are always 
    calculated anew for multiple data sets).

o   removed note in documentation that gen.X functions are rather 
    new. They are well tested by now.
o   bmpt.fia should now work without snowfall without throwing a

                ** MPTinR VERSION 1.6.x **
                Changes in MPTinR Version 1.6.x
                Released October 2014

Significant User Visible Changes and new Features

o   numDeriv is now only imported and not attached.

o   names for models passed to select.mpt are now automatically 
    determined via
o   changed the maintainer email address.


o   C++ code now uses Rcpp attributes.

o   A bug prohibiting computation of FIA for models without 
    inequality restrictions and with DEBUG flags enabled when 
    compiling should now be resolved. The computation causing it is
    skipped when no inequalities are present.

o   calculating FIA via fit.model did not work for individual data  
o   get.mpt.fia: added examples outside dontrun{} blocks running 
    simple fia tests, with and without inequalities.
o   all calls to snowfall prefaced with snowfall:: to avoid CRAN 

                ** MPTinR VERSION 1.5.x **
                Changes in MPTinR Version 1.5.x
                Released August 2014

Significant User Visible Changes and new Features

o   added numDeriv argument to fit functions (fit.mpt, fit.model, &
    fit.mptinr) which allows to deactivate numerical estimation of 
    hessian (for calculation of CIs) as it may be extremely time 



                ** MPTinR VERSION 1.4.x **
                Changes in MPTinR Version 1.4.x
                Released May 2014

Significant User Visible Changes and new Features



o   repaired mConst argument and FIA function.

                ** MPTinR VERSION 1.3.x **
                Changes in MPTinR Version 1.3.x
                Released April 2014

Significant User Visible Changes and new Features

o   added args.fia argument to fit.mpt and fit.model to pass
    arguments to get.mpt.fia (such as mConst, see below).
o   added function to transform a model in
    LBMPT into model equations (thanks to Quentin Gronau 
    and Franz Dietrich).
o   added restrictions argument to

o   added example on how to fit a confidence rating SDT model to


o   added mConst argument to bmpt.fia (+ get.mpt.fia) to avoid
    numerical underflows with huge models when calculating FIA.
    (this argument should be used carefully).
o   check.model argument in fit.model was also responsible 
    for certain sanity checks in the objective et al.
    This frequently led to errors which are now silently
                ** MPTinR VERSION 1.2.x **
                Changes in MPTinR Version 1.2.x
                Released November 2013

Significant User Visible Changes and new Features

o   Most warnings (e.g., concerning unsuccessful optimization
    with analytic gradient) are now messages.

o   Added error message when the objective function did not 
    evaluate successfully with the given starting values.
o   restrictions to constants can now be set to any value 
    (not anymore restricted to be within 0 and 1).
o   fit.model and gen.predictions (et al.) have argument 
    check.model which allows to suppress the check if the 
    expected values of a model sum to 1.


o   Removed bug that crashed the main functions when Hessian
    function failed to produce reasonable results. 

o   FIA calculation could fail when determinant of Fisher matrix 
    was below 0 as it did not take the absolute value 
    (as does the original code by Wu et al.). This should be
    fixed now and FIA again works for all (BMPT) models.

o   check.mpt doesn't fail anymore if any of the predictions is 
    NA or NaN.
o   Removed bug that crashed MPTinR when fitting a model with a 
    single free parameter to multiple datasets (bug reported by
    Alberto Mirisola)
o   fit.mpt gives a warning when FIA fails due to model not being
    a BMPT (instead of failing).
                ** MPTinR VERSION 1.1.x **
                Changes in MPTinR Version 1.1.x
                Released May 2013

Significant User Visible Changes and new Features

o   Calculation of FIA uses RcppEigen for dramatic speed
    improvements (thanks to Christian Mueller).

o   FIA calculation can also be parallelized, see bmpt.fia 
    (but even in fit.mpt or fit.model, if multicore is not "none",
    or in get.mpt.fia)

o   documentation now says that extra brackets will distort FIA 
    calculation (Thanks to Joachim Vandekerckhove and 
    EJ Wagenmakers)
o   added possibility to specify individual bounds for 
    random starting values (via two element list).

o   multicore fitting now uses load balancing.

o   select.mpt shows how often p < .05 when results consists
    of multiple data sets. (p.smaller.05)


o   Added note that LLKs do not include factorial constant of the
    multinomial PMF.
o   (hopefully) repaired bug in make.mdt() with matrix/data.frame

                ** MPTinR VERSION 1.0.x **
                Changes in MPTinR Version 1.0.x
                Released January 2013

Significant User Visible Changes and new Features

o   added function plot.prediction for plotting obersved versus 
    predicted data.

o   added fia.penalty to information criteria output and to select.mpt.

o   added G.Square, df, and p to output of select.mpt

o   argument dataset added to select.mpt. Allows to select only certain 
    datasets for the comparison (argument may be of length > 1).

o   added CITATION file (as our Behavior Research Methods paper finally 
    came out)


o   select.mpt works now if some some models (with multiple datasets)
    were fitted with fit.aggregated = FALSE.
o   select.mpt returns the aggregated GoF (G^2, df, p) when output = "full"
o   You can now pose an order restriction on variables that may also
    be restricted to be equal to others. E.g., the following restriction
    is allowed list("G2 < G3 < G5", "G1 = G2", "G4 = G5") and produces
    the desired results, see r-forge/MPTinR/bugs/restrictionsbug.order.R 
    Note that in this case G1 would be marked as inequality restricted
    instead of equality restricted (which is not the case for G4).

                ** MPTinR VERSION 0.9.x **
                Changes in MPTinR Version 0.9.x
                Released July 2012

Significant User Visible Changes and new Features

o   added functions, and gen.predictions
    for bootstrapping, generating data and predictions.

o   coments in model and restrictions files are now treated as in R:
    Everything to the right of a # is ignored and NOT the whole line!

o   MPTinR is now byte compiled.

o   make.mdt can now handle a matrix or data.frames building a big mdt file.


o   fixed bug when obtaining fia from textConnection also for fit.model()

                ** MPTinR VERSION 0.8.x **
                Changes in MPTinR Version 0.8.x
                Released February - May 2012

Significant User Visible Changes and new Features

o   fit.mpt and fit.model (see version 0.7.0) are now just wrappers around 
    the new function fit.mptinr. They produce the appropirate objective, gradient,
    hessian, and prediction function to fit the model.
o   fit.model contains an example of how to fit a SDT. see ?fit.model. 
    Dont forget to set lower.bound and upper.bound when fitting non-MPT models.

o   fit.mptinr is a new function that takes an arbitrary objective function and 
    possibly a gradient, hessian and prediction function to fit categorical
    data (see examples in ?fit.model).

o   fitting for MPT and similar models is done using a gradient function,
    which significantly improves fitting speed. In the rare cases where fitting 
    fails using the gradient a numerical gradient is still used (with warning).
o   The Hessian Matrix for MPTs and similar models is now symbolically 
    derived yielding an exact Hessian matrix (before it was numerically estimated 
    leading to incorrect Hessians whean paramaters were exactly at the boundary).
o   fitting is now based on nlminb instead of optim's L-BFGS-B
    (using L-BFGS-B is available in fit.mpt.old)

o   models and restrictions can now be specified using textConnections instead of 
    only external files. See examples in ?fit.mpt and especially ?fit.model. 
    restrictions can be specified as a list of characters.

o   added make.mdt, a function to make .mdt data files which can be read by multiTree 
    or HMMTree.
o   new argument show.messages added to the fitting function (default = TRUE). If 
    FALSE the time messeages around the fitting algorithm are suppressed. 
o   expanded check.mpt functionality (now gives number of categories and 
    number of independent categories)

o   all fitting functions have the argument fit.aggregated to indicate whether or not
    the aggregated data (for multiple datasets) should be fitted. Default is TRUE

o   summary.llks was renamed to fitting.runs

o now gives the rank of the Fisher Matrix (instead of the rank of the Hessian Matrix).


o   resolved small bug when fitting using multicore = "individual"

o   no more warning message if CIs cannot be computed.

o   select.mpt now compares aggregated FIA for output = "full"

o   select.mpt now rounds information criteria before determining number of 
    best fits

o   no more warnings by cell counts below 5 (seems unprincipled)
o   fixed bug when restricted parameters were not in the original model
    (now throws a warning, thanks to Alex)

                ** MPTinR VERSION 0.7.0 **
                Changes in MPTinR Version 0.7.0
                Released January 2012

Significant User Visible Changes

o   now contains fit.model() a copy of fit.mpt() with arguments for lower and upper bounds
    for the parameters. You should be able to fit a lot more models with this function.
    (fit.model() is slightly slower than fit.mpt() for MPTs)

New Features / Bugfixes

o   MPTinR should now allow easy model files with all types of operators (not only + - *) 
    and even R functions (e.g., pnorm, ...) via the function fit.model()

                ** MPTinR VERSION 0.6.5 **
                Changes in MPTinR Version 0.6.5
                Released June 2011

Significant User Visible Changes


New Features / Bugfixes

o   added a parameter to specify the starting values for the fitting routine (in fit.mpt)

                ** MPTinR VERSION 0.6.4 **
                Changes in MPTinR Version 0.6.4
                Released June 2011

Significant User Visible Changes


New Features / Bugfixes

o   added URL to DESCRIPTION file.

o   corrected more problems in bmpt.fia when using small models that
    were related to differences in matrix functionality of Matlab
    and R (the problem is R's default of '[', drop = TRUE).

                ** MPTinR VERSION 0.6.3 **
                Changes in MPTinR Version 0.6.3
                Released April 2011

Significant User Visible Changes

o   get.mpt.fia modified such that bmpt.fia is only called as often as
    there are differences in the hank.join parameters (i.e., only if
    the ratio between the trees differ, not the ns). As a consequence,
    CFIA is calculated as part of get.mpt.fia. Furthermore, CIs of CFIA
    are not returned by get.mpt.fia.

o   fit.mpt adjusted to use the optimization of get.mpt.fia (see above)
    for multi-individual fit. That is, fit.mpt now calls get.mpt.fia
    only once (previous were two calls, one for for individual data,
    one for aggregated data).

o   objective function in fit.mpt vectorized (previous was using
    for-loop). Obtained speed up: ~40%.

New Features / Bugfixes

o   bmpt.fia fixed to deal with models without restricted parameters
    (was necessary as we did not use en empty matrix correctly)

o   Corrected a bug that lead to a wrong labeling of restricted
    parameters in the mean parameter table for multi-individual fit
    when using sort.param = TRUE.

o   Corrected a bug in the R implementation of bmpt.fia, when only one
    parameter was fixed.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.14.1 by Henrik Singmann, 7 months ago

Browse source code at

Authors: Henrik Singmann [aut, cre] , David Kellen [aut] , Quentin Gronau [aut] , Christian Mueller [ctb] , Akhil S Bhel [ctb]

Documentation:   PDF Manual  

Task views: Psychometric Models and Methods

GPL (>= 2) license

Imports numDeriv, Brobdingnag, Rcpp, stats, utils

Suggests snowfall, knitr

Linking to Rcpp, RcppEigen

Imported by MPTmultiverse.

See at CRAN