Skip to contents

Fits a univariate Gaussian mixture model by maximum likelihood with the standard EM algorithm. This is the `beta = 0` special case of [robustGMM()] and serves as the non-robust baseline.

Usage

vanillaGMM(
  x,
  lambda = NULL,
  mu = NULL,
  sigma = NULL,
  tol = 1e-06,
  maxiter = 1000,
  verbose = FALSE,
  keep.data = FALSE
)

Arguments

x

`numeric(n)` - A numeric vector of observations

lambda

`numeric` - Vector of mixing proportions of each normal component

mu

`numeric` - Vector of means of each normal component

sigma

`numeric` - Vector of standard deviations of each normal component

tol

Convergence tolerance on the change in beta-likelihood.

maxiter

Max iteration.

verbose

Print iteration progress.

keep.data

Keep a copy of `x` in the returned object.

Value

A list with elements `lambda`, `mu`, `sigma`, `l` (log-likelihood), `iter`, and `converged`. If `maxiter` is reached before convergence, the last iterate is returned with `converged = FALSE` and a warning.

Examples

set.seed(404)
x <- rnormix(100, c(0.25, 0.75), c(0, 4), c(1, 1))
vanillaGMM(x, c(0.25, 0.75), c(0, 4), c(1, 1))
#> $lambda
#> [1] 0.2881969 0.7118031
#> 
#> $mu
#> [1] 0.221318 4.014146
#> 
#> $sigma
#> [1] 1.2099568 0.9086821
#> 
#> $l
#> [1] -192.2994
#> 
#> $iter
#> [1] 38
#> 
#> $converged
#> [1] TRUE
#>