Learn R Programming

mixtools (version 2.0.0)

mvnormalmixEM: EM Algorithm for Mixtures of Multivariate Normals

Description

Return EM algorithm output for mixtures of multivariate normal distributions.

Usage

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

Value

normalmixEM returns a list of class mixEM with items:

x

The raw data.

lambda

The final mixing proportions.

mu

A list of with the final mean vectors.

sigma

A list with the final variance-covariance matrices.

loglik

The final log-likelihood.

posterior

An nxk matrix of posterior probabilities for observations.

all.loglik

A vector of each iteration's log-likelihood.

restarts

The number of times the algorithm restarted due to unacceptable choice of initial values.

ft

A character vector giving the name of the function.

Arguments

x

A matrix of size nxp 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 list of size k consisting of initial values for the p-vector mean parameters. If NULL, then the vectors are generated from a normal distribution with mean and standard deviation according to a binning method done on the data. If both lambda and mu are NULL, then number of components is determined by sigma.

sigma

A list of size k consisting of initial values for the pxp variance-covariance matrices. If NULL, then sigma is generated using the data. If lambda, mu, and sigma are NULL, then number of components is determined by k.

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.

References

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

See Also

normalmixEM

Examples

Run this code
##Fitting randomly generated data with a 2-component location mixture of bivariate normals.

set.seed(100)
x.1 <- rmvnorm(40, c(0, 0))
x.2 <- rmvnorm(60, c(3, 4))
X.1 <- rbind(x.1, x.2)
mu <- list(c(0, 0), c(3, 4))

out.1 <- mvnormalmixEM(X.1, arbvar = FALSE, mu = mu,
                       epsilon = 1e-02)
out.1[2:5]

##Fitting randomly generated data with a 2-component scale mixture of bivariate normals.

x.3 <- rmvnorm(40, c(0, 0), sigma = 
               matrix(c(200, 1, 1, 150), 2, 2))
x.4 <- rmvnorm(60, c(0, 0))
X.2 <- rbind(x.3, x.4)
lambda <- c(0.40, 0.60)
sigma <- list(diag(1, 2), matrix(c(200, 1, 1, 150), 2, 2))
 
out.2 <- mvnormalmixEM(X.2, arbmean = FALSE,
                       sigma = sigma, lambda = lambda,
                       epsilon = 1e-02)
out.2[2:5]

Run the code above in your browser using DataLab