NMixEM                 package:mixAK                 R Documentation

_E_M _a_l_g_o_r_i_t_h_m _f_o_r _a _h_o_m_o_s_c_e_d_a_s_t_i_c _n_o_r_m_a_l _m_i_x_t_u_r_e

_D_e_s_c_r_i_p_t_i_o_n:

     This function computes ML estimates of the parameters of the
     p-dimensional K-component normal mixture using the EM algorithm

_U_s_a_g_e:

     NMixEM(y, K, weight, mean, Sigma, toler=1e-5, maxiter=500)

     ## S3 method for class 'NMixEM':
     print(x, ...)

_A_r_g_u_m_e_n_t_s:

       y: vector (if p=1) matrix or data frame (if p > 1) with data.
          Rows correspond to observations, columns correspond to
          margins.

       K: required number of mixture components.

  weight: a numeric vector with initial mixture weights.

          If not given, initial weights are all equal to 1/K. 

    mean: vector or matrix of initial mixture means.

          For p=1 this should be a vector of length K, for p>1 this
          should be a K x p matrix with mixture means in rows. 

   Sigma: number or p x p matrix giving the initial variance/covariance
          matrix. 

   toler: tolerance to determine convergence.

 maxiter: maximum number of iterations of the EM algorithm.

       x: an object of class 'NMixEM'.

     ...: additional arguments passed to the default 'print' method.

_V_a_l_u_e:

     An object of class 'NMixEM' which has the following components: 

       K: number of mixture components

  weight: estimated mixture weights

    mean: estimated mixture means

   Sigma: estimated covariance matrix

  loglik: log-likelihood value at fitted values

    iter: number of iterations of the EM algorithm used to get the
          solution

iter.loglik: values of the log-likelihood at iterations of the EM
          algorithm

iter.Qfun: values of the EM objective function at iterations of the EM
          algorithm

     dim: dimension p

    nobs: number of observations n

_A_u_t_h_o_r(_s):

     Arno&#353t Kom&#225rek arnost.komarek[AT]mff.cuni.cz

_R_e_f_e_r_e_n_c_e_s:

     Dempster, A. P., Laird, N. M., Rubin, D. B. (1977). Maximum
     likelihood from incomplete data via the EM algorithm. _Journal of
     the Royal Statistical Society, Series B_, *39*, 1-38.

_E_x_a_m_p_l_e_s:

     ## Estimates for 3-component mixture in  Anderson's iris data
     ## ==========================================================
     data(iris, package="datasets")
     summary(iris)

     VARS <- names(iris)[1:4]
     fit <- NMixEM(iris[, VARS], K = 3)
     print(fit)

     apply(subset(iris, Species == "versicolor")[, VARS], 2, mean)
     apply(subset(iris, Species == "setosa")[, VARS], 2, mean)
     apply(subset(iris, Species == "virginica")[, VARS], 2, mean)

     ## Estimates of 6-component mixture in Galaxy data
     ## ==================================================
     data(Galaxy, package="mixAK")
     summary(Galaxy)

     fit2 <- NMixEM(Galaxy, K = 6)
     y <- seq(5, 40, length=300)
     fy <- dMVNmixture(y, weight=fit2$weight, mean=fit2$mean,
                          Sigma=rep(fit2$Sigma, fit2$K))
     hist(Galaxy, prob=TRUE, breaks=seq(5, 40, by=0.5),
          main="", xlab="Velocity (km/sec)", col="sandybrown")
     lines(y, fy, col="darkblue", lwd=2)

