fit_gammamix | R Documentation |
Fits a mixture of gamma distributions to a data set using the EM algorithm.
fit_gammamix(x, k, max_iter = 2500, tol = 1e-04)
x |
a numeric vector of data values. |
k |
a number indicating the number of mixture components. |
max_iter |
a number indicating the maximum number of iterations of the EM algorithm. |
tol |
a number determining the convergence criteria. The algorithm stops if the change in the log-likelihood function is smaller than tol. |
This function estimates the parameters of a mixture of Gamma distributions using the EM algorithm described in Almhana et al. The stopping criteria is defined through the absolute difference between the log-likelihood function of two iterations.
fit_gammamix
returns a list with the fitted parameters, the number
of iterations, and the value of the log-likelihood function at the fitted
parameters.
w
, rate
, and shape
are the fitted weight, rate, and shape
parameter, respectively.
The value of the log-likelihood function and the number of iterations can
be accessed through loglikeli
and iter
.
Almhana J, Liu Z, Choulakian V, McGorman R. A recursive algorithm for gamma mixture models. IEEE International Conference on Communications 2006 (ICC 2006) 1:197-202. DOI: 10.1109/ICC.2006.254727. Link: http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=4024117
set.seed(100) shape <- c(10, 3) rate <- c(14, 3) x <- c(rgamma(290, shape = shape[1], rate = rate[1]), rgamma(710, shape = shape[2], rate = rate[2])) fit_gammamix(x, k = 2, max_iter = 2500, tol = 1e-5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.