Learn R Programming

mixtools (version 2.0.0)

gammamixEM: EM Algorithm for Mixtures of Gamma Distributions

Description

Return EM algorithm output for mixtures of gamma distributions.

Usage

gammamixEM(x, lambda = NULL, alpha = NULL, beta = NULL, k = 2,
           mom.start = TRUE, fix.alpha = FALSE, epsilon = 1e-08, 
           maxit = 1000, maxrestarts = 20, verb = FALSE)

Value

gammamixEM returns a list of class mixEM with items:

x

The raw data.

lambda

The final mixing proportions.

gamma.pars

A 2xk matrix where each column provides the component estimates of alpha and beta.

loglik

The final log-likelihood.

posterior

An nxk matrix of posterior probabilities for observations.

all.loglik

A vector of each iteration's log-likelihood. This vector includes both the initial and the final values; thus, the number of iterations is one less than its length.

ft

A character vector giving the name of the function.

Arguments

x

A vector of length n consisting of the data.

lambda

Initial value of mixing proportions. If NULL, then lambda is random from a uniform Dirichlet distribution (i.e., its entries are uniform random and then it is normalized to sum to 1).

alpha

Starting value of vector of component shape parameters. If non-NULL, alpha must be of length k if allowing different component shape parameters, or a single value if fix.alpha = TRUE. If NULL, then the initial value is estimated by partitioning the data into k regions (with lambda determining the proportion of values in each region) and then calculating the method of moments estimates.

beta

Starting value of vector of component scale parameters. If non-NULL and a vector, k is set to length(beta). If NULL, then the initial value is estimated the same method described for alpha.

k

Number of components. Initial value ignored unless alpha and beta are both NULL.

mom.start

Logical to indicate if a method of moments starting value strategy should be implemented. If TRUE, then only unspecified starting values will be generated according to this strategy.

epsilon

The convergence criterion. Convergence is declared when the change in the observed data log-likelihood increases by less than epsilon.

fix.alpha

Logical to indicate if the components should have a common shape parameter alpha estimated. The default is FALSE.

maxit

The maximum number of iterations.

maxrestarts

The maximum number of restarts allowed in case of a problem with the particular starting values chosen (each restart uses randomly chosen starting values).

verb

If TRUE, then various updates are printed during each iteration of the algorithm.

References

Dempster, A. P., Laird, N. M., and Rubin, D. B. (1977) Maximum Likelihood From Incomplete Data Via the EM Algorithm, Journal of the Royal Statistical Society, Series B, 39(1), 1--38.

Young, D. S., Chen, X., Hewage, D., and Nilo-Poyanco, R. (2019) Finite Mixture-of-Gamma Distributions: Estimation, Inference, and Model-Based Clustering, Advances in Data Analysis and Classification, 13(4), 1053--1082.

Examples

Run this code
##Analyzing a 3-component mixture of gammas.

set.seed(100)
x <- c(rgamma(200, shape = 0.2, scale = 14), rgamma(200, 
     shape = 32, scale = 10), rgamma(200, shape = 5, scale = 6))
out <- gammamixEM(x, lambda = c(1, 1, 1)/3, verb = TRUE)
out[2:4]

Run the code above in your browser using DataLab