fit_gammamix: Fit gamma mixture distribution

View source: R/fit_gammamix.R

fit_gammamixR Documentation

Fit gamma mixture distribution

Description

Fits a mixture of gamma distributions to a data set using the EM algorithm.

Usage

fit_gammamix(x, k, max_iter = 2500, tol = 1e-04)

Arguments

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.

Details

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.

Value

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.

References

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

Examples

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)

tobiasmuetze/varmap documentation built on Dec. 8, 2022, 2:16 p.m.