mxExpectationMixture {OpenMx}R Documentation

Mixture expectation

Description

Used in conjuction with mxFitFunctionML, this expectation can express a mixture model.

Usage

mxExpectationMixture(components, weights="weights",
		      ..., verbose=0L, scale=c('softmax','sum'))

Arguments

components

A character vector of model names.

weights

The name of the matrix or algebra column that specifies the component weights.

...

Not used. Forces remaining arguments to be specified by name.

verbose

the level of runtime diagnostics

scale

How the probabilities are rescaled. For 'softmax', the coefficient-wise exponential is taken and then each column is divided by its column sum. For 'sum', each column is divided by its column sum.

Details

The mixture probabilities given in weights must sum to one. As such for K mixture components, only K-1 of the elements of weights can be estimated.

For ease of use the raw free parameters of weights are rescaled by OpenMx according to the scale argument. When scale is set to "softmax" the softmax function is applied to the weights. The softmax function is also sometimes called multinomial logistic regression. Softmax exponentiates each element in a vector and then divides each element by the sum of the exponentiated elements. In equation form the softmax function is

softmax(x_i) = exp(x_i) / sum(exp(x_i))

When using the softmax scaling no free parameter bounds or constraints are needed. However, for model identification, one element of the weights vector must be fixed. If the softmax scaling is used, then the usual choise for the fixed parameter value is zero. The latent class or mixture component that has its raw weight set to zero becomes the comparison against which other probabilities are evaluated.

When scale is set to "sum" then each element of the weights matrix is internally divided by its sum. When using the sum scaling, the same model identification requirements are present. In particular, one element of the weights must be fixed. The typical value to fix this value at for sum scaling is one. Additionally when using sum scaling, all free parameters in the weights must have lower bounds of zero. In equation form the sum scaling does the following:

sumscale(x_i) = x_i / sum(x_i)

Parameters are estimated in the given scale. To obtain the weights column vector, examine the expectation's output slot with for example yourModel$expectation$output

An extension of this expectation to a Hidden Markov model is available with mxExpectationHiddenMarkov. mxGenerateData is not implemented for this type of expectation.

Examples

library(OpenMx)

set.seed(1)

trail <- c(rep(1,480), rep(2,520))
trailN <- sapply(trail, function(v) rnorm(1, mean=v))

classes <- list()

for (cl in 1:2) {
  classes[[cl]] <- mxModel(paste0("class", cl), type="RAM",
                           manifestVars=c("ob"),
                           mxPath("one", "ob", value=cl, free=FALSE),
                           mxPath("ob", arrows=2, value=1, free=FALSE),
                           mxFitFunctionML(vector=TRUE))
}

mix1 <- mxModel(
  "mix1", classes,
  mxData(data.frame(ob=trailN), "raw"),
  mxMatrix(values=1, nrow=1, ncol=2, free=c(FALSE,TRUE), name="weights"),
  mxExpectationMixture(paste0("class",1:2), scale="softmax"),
  mxFitFunctionML())

mix1Fit <- mxRun(mix1)

[Package OpenMx version 2.8.3 Index]