Return EM algorithm output for mixtures of gamma distributions.
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)
gammamixEM
returns a list of class mixEM
with items:
The raw data.
The final mixing proportions.
A 2xk matrix where each column provides the component estimates of alpha
and beta
.
The final log-likelihood.
An nxk matrix of posterior probabilities for observations.
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.
A character vector giving the name of the function.
A vector of length n consisting of the data.
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).
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.
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
.
Number of components. Initial value ignored unless alpha
and beta
are both NULL.
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.
The convergence criterion. Convergence is declared when the change in the observed data log-likelihood increases by less than epsilon.
Logical to indicate if the components should have a common shape parameter alpha
estimated. The default is FALSE
.
The maximum number of iterations.
The maximum number of restarts allowed in case of a problem with the particular starting values chosen (each restart uses randomly chosen starting values).
If TRUE, then various updates are printed during each iteration of the algorithm.
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.
##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