Learn R Programming

epigenomix (version 1.12.0)

mlMixModel: Fits a mixture model using the maximum likelihood principle.

Description

This method calculates the maximum likelihood estimations of a mixture model using the expectation-maximization (EM) algorithm. The mixture model may consists of normal components (with a fixed expectation of 0) and exponential components, which may be mirrored in order to model negative values.

Usage

mlMixModel(z, normNull = c(), expNeg = c(), expPos = c(), sdNormNullInit = c(), rateExpNegInit = c(), rateExpPosInit = c(), piInit = c(), maxIter = 500, tol = 0.001)

Arguments

z
Observed values.
normNull
Indices of the normal components (that have $mu=0$).
expNeg
Indices of the mirrored exponential components.
expPos
Indices of the exponential components.
sdNormNullInit
Initial standard deviations of the normal components.
rateExpNegInit
Initial rates ("lambda") of the exponential components.
rateExpPosInit
Initial rates ("lambda") of the exponential components.
piInit
Initial weights of the components.
maxIter
Maximum number of iterations.
tol
Threshold for convergence. The minimum log likelihood gain between two iterations that must be achieved to continue.

Value

An object of MixModelML-class storing results, data, initial values and information about the convergence.

Details

The EM algorithm is known to converge slowly in some cases and local maxima may avoid finding the optimal solution. Users should try different initial values and different convergence criteria.

The components' indices do not influence the result, but may influence the order in which components are listed or ploted by downstream methods. Indices must be successive integers from 1 to n.

See Also

MixModelML-class

Examples

Run this code
z <- c(rnorm(1000, 0, 0.5), rnorm(1000, 0, 1))
mm <- mlMixModel(z, normNull=1:2, sdNormNullInit=c(0.1, 0.2),
   pi=c(1/2, 1/2), maxIter=500, tol=0.001)
mm

z <- c(rnorm(1000, 0, 3), rnorm(1000, 0, 5), rexp(1000, 5), -rexp(1000, 5))
mm <- mlMixModel(z, normNull=1:2, expNeg=3, expPos=4,
   sdNormNullInit=c(1, 2), rateExpNegInit=8, rateExpPosInit=8,
   pi=c(1/4, 1/4, 1/4, 1/4), maxIter=500, tol=0.001)
mm

Run the code above in your browser using DataLab