gammamixEM {mixtools} | R Documentation |
Return EM algorithm output for mixtures of gamma distributions.
gammamixEM(x, lambda = NULL, alpha = NULL, beta = NULL, k = 2, epsilon = 1e-08, maxit = 1000, maxrestarts=20, verb = FALSE)
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 and a vector,
k is set to length(alpha) . 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. |
epsilon |
The convergence criterion. Convergence is declared when the change in the observed data log-likelihood increases by less than epsilon. |
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. |
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. |
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.
##Analyzing a 3-component mixture of gammas. 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]