Learn R Programming

mixtools (version 0.1.0)

normalmixEM: EM Algorithm for Mixtures of Univariate Normals

Description

Return EM algorithm output for mixtures of normal distributions.

Usage

normalmixEM(x, lambda = NULL, mu = NULL, sigma = NULL, k = 2,
            arbmean = TRUE, arbvar = TRUE, epsilon = 1e-08, 
            maxit = 10000, verb = FALSE)

Arguments

x
A vector of length n consisting of the data.
lambda
Initial value of mixing proportions. Entries should sum to 1. This determines number of components. If NULL, then lambda is random from uniform Dirichlet and number of components is determined by mu.
mu
A k-vector of initial values for the mean parameters. If NULL, then the vector is generated from a normal distribution according to a binning method done on the data. If both lambda and mu are NULL, then number of com
sigma
A k-vector of initial values for the standard deviation parameters. If NULL, then 1/sigma$^2$ has random exponential entries according to a binning method done on the data. If lambda, mu, and sigm
k
Number of components. Ignored unless lambda, mu, and sigma are all NULL.
arbmean
If TRUE, then the component densities are allowed to have different mus. If FALSE, then a scale mixture will be fit.
arbvar
If TRUE, then the component densities are allowed to have different sigmas. If FALSE, then a location mixture will be fit.
epsilon
The convergence criterion.
maxit
The maximum number of iterations.
verb
If TRUE, then various updates are printed during each iteration of the algorithm.

Value

  • normalmixEM returns a list of class mixEM with items:
  • xThe raw data.
  • lambdaThe final mixing proportions.
  • muThe final mean parameters.
  • sigmaThe final standard deviations. If arbmean = FALSE, then only the smallest standard deviation is returned. See scale below.
  • scaleIf arbmean = FALSE, then the scale factor for the component standard deviations is returned. Otherwise, this is omitted from the output.
  • loglikThe final log-likelihood.
  • posteriorAn nxk matrix of posterior probabilities for observations.
  • all.loglikA vector of each iteration's log-likelihood.
  • ftA character vector giving the name of the function.

References

McLachlan, G. J. and Peel, D. (2000) Finite Mixture Models, John Wiley & Sons, Inc.

See Also

mvnormalmixEM

Examples

Run this code
##Analyzing the Old Faithful geyser data with a 2-component mixture of normals.

data(faithful)
attach(faithful)
out<-normalmixEM(waiting, arbvar = FALSE)
out

Run the code above in your browser using DataLab