# mptmix: Finite Mixtures of Multinomial Processing Tree Models In psychomix: Psychometric Mixture Models

## Description

Fit finite mixtures of multinomial processing tree (MPT) models via maximum likelihood with the EM algorithm.

## Usage

 ```1 2 3 4 5 6 7 8``` ```mptmix(formula, data, k, subset, weights, nrep = 3, cluster = NULL, control = NULL, verbose = TRUE, drop = TRUE, unique = FALSE, which = NULL, spec, treeid = NULL, optimargs = list(control = list(reltol = .Machine\$double.eps^(1/1.2), maxit = 1000)), ...) FLXMCmpt(formula = . ~ ., spec = NULL, treeid = NULL, optimargs = NULL, ...) ```

## Arguments

 `formula` Symbolic description of the model (of type `y ~ 1` or `y ~ x`). `data, subset` Arguments controlling formula processing. `k` A vector of integers indicating the number of components of the finite mixture; passed in turn to the `k` argument of `stepFlexmix`. `weights` An optional vector of weights to be used in the fitting process; passed in turn to the `weights` argument of `flexmix`. `nrep` Number of runs of the EM algorithm. `cluster` Either a matrix with `k` columns of initial cluster membership probabilities for each observation; or a factor or integer vector with the initial cluster assignments of observations at the start of the EM algorithm. Default is random assignment into `k` clusters. `control` An object of class `"FLXcontrol"` or a named list; controls the EM algorithm and passed in turn to the `control` argument of `flexmix`. `verbose` A logical; if `TRUE` progress information is shown for different starts of the EM algorithm. `drop` A logical; if `TRUE` and `k` is of length 1, then a single `mptmix` object is returned instead of a `stepMPTmix` object. `unique` A logical; if `TRUE`, then `unique()` is called on the result; for details see `stepFlexmix`. `which` number of model to get if `k` is a vector of integers longer than one. If character, interpreted as number of components or name of an information criterion. `spec, treeid, optimargs` arguments for the MPT model passed on to `mptmodel`. `...` Currently not used.

## Details

Internally `stepFlexmix` is called with suitable arguments to fit the finite mixture model with the EM algorithm.

`FLXMCmpt` is the `flexmix` driver for MPT mixture models.

The interface is designed along the same lines as `raschmix` which is introduced in detail in Frick et al. (2012). However, the `mptmix` function has not yet been fully tested and may change in future versions.

The latent-class MPT model (Klauer, 2006) is equivalent to an MPT mixture model without concomitant variables.

MPT models are specified using the `mptspec` function. See the documentation in the mpt package for details.

## Value

Either an object of class `"mptmix"` containing the best model with respect to the log-likelihood (if `k` is a scalar) or the one selected according to `which` (if specified and `k` is a vector of integers longer than 1) or an object of class `"stepMPTmix"` (if `which` is not specified and `k` is a vector of integers longer than 1).

## References

Frick, H., Strobl, C., Leisch, F., and Zeileis, A. (2012). Flexible Rasch Mixture Models with Package psychomix. Journal of Statistical Software, 48(7), 1–25. http://www.jstatsoft.org/v48/i07/

Klauer, K.C. (2006). Hierarchical Multinomial Processing Tree Models: A Latent-Class Approach. Psychometrika, 71, 7–31. doi: 10.1007/s11336-004-1188-3

`flexmix`, `stepFlexmix`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19``` ```## Data data("PairClustering", package = "psychotools") pc <- reshape(PairClustering, timevar = "trial", idvar = "ID", direction = "wide") ## Latent-class MPT model (Klauer, 2006) suppressWarnings(RNGversion("3.5.0")) set.seed(1) m <- mptmix(as.matrix(pc[-1]) ~ 1, data = pc, k = 1:3, spec = mptspec("SR", .replicates = 2)) m1 <- getModel(m, which = "BIC") ## Inspect results summary(m1) parameters(m1) plot(m1) library(lattice) xyplot(m1) ```