cdens                 package:mclust                 R Documentation

_C_o_m_p_o_n_e_n_t _D_e_n_s_i_t_y _f_o_r _P_a_r_a_m_e_t_e_r_i_z_e_d _M_V_N _M_i_x_t_u_r_e _M_o_d_e_l_s

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

     Computes component densities for observations in parameterized MVN
     mixture models.

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

     cdens(modelName, data, mu, ...)

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

modelName: A character string indicating the model. Possible models: 

           "E" for spherical, equal variance (one-dimensional) 
           "V" for spherical, variable variance (one-dimensional) 

           "EII": spherical, equal volume 
           "VII": spherical, unequal volume 
           "EEI": diagonal, equal volume, equal shape 
           "VEI": diagonal, varying volume, equal shape 
           "EVI": diagonal, equal volume, varying shape 
           "VVI": diagonal, varying volume, varying shape 
           "EEE": ellipsoidal, equal volume, shape, and orientation 
           "EEV": ellipsoidal, equal volume and equal shape
           "VEV": ellipsoidal, equal shape 
           "VVV": ellipsoidal, varying volume, shape, and orientation 

           For fitting a single Gaussian:

               "X": one-dimensional 
           "XII": spherical 
           "XXI": diagonal 
           "XXX": ellipsoidal 

    data: A numeric vector, matrix, or data frame of observations.
          Categorical variables are not allowed. If a matrix or data
          frame, rows correspond to observations and columns correspond
          to variables.  

      mu: The mean for each component. If there is more than one
          component, 'mu' is a matrix whose columns are the means of
          the components. 

     ...: Arguments for model-specific functions. Specifically:

             *  'logarithm': A logical value indicating whether or not
                the logarithm of the component densities should be
                returned. The default is to return the component
                densities, obtained from the log component densities by
                exponentiation.

             *  An argument describing the variance (depends on the
                model):

             _s_i_g_m_a_s_q for the one-dimensional models ("E", "V") and
                  spherical models ("EII", "VII"). This is either a
                  vector whose _k_th component is the variance for the
                  _k_th component in the mixture model ("V" and "VII"),
                  or a scalar giving the common variance for all
                  components in the mixture model ("E" and "EII").

             _d_e_c_o_m_p for the diagonal models ("EEI", "VEI", "EVI",
                  "VVI") and some ellipsoidal models ("EEV", "VEV").
                  This is a list with the following components:

                  _d The dimension of the data.

                  _G The number of components in the mixture model.

                  _s_c_a_l_e Either a _G_-vector giving the scale of the
                       covariance (the _d_th root of its determinant)
                       for each component in the mixture model, or a
                       single numeric value if the scale is the same
                       for each component.

                  _s_h_a_p_e Either a _G_ by _d_ matrix in which the _k_th
                       column is the shape of the covariance matrix
                       (normalized to have determinant 1) for the _k_th
                       component, or a _d_-vector giving a common shape
                       for all components.

                  _o_r_i_e_n_t_a_t_i_o_n Either a _d_ by _d_ by _G_ array whose
                       '[,,k]'th entry is the orthonomal matrix of
                       eigenvectors of the covariance matrix of the
                       _k_th component, or a _d_ by _d_ orthonormal
                       matrix if the mixture components have a common
                       orientation. The 'orientation' component of
                       'decomp' can be omitted in spherical and
                       diagonal models, for which the principal
                       components are parallel to the coordinate axes
                       so that the orientation matrix is the identity.


             _S_i_g_m_a for the equal variance model "EEE". A _d_ by _d_
                  matrix giving the common covariance for all
                  components of the mixture model.

             _s_i_g_m_a for the unconstrained variance model "VVV". A _d_ by
                  _d_ by _G_ matrix array whose '[,,k]'th entry is the
                  covariance matrix for the _k_th component of the
                  mixture model.

                  The form of the variance specification is the same as
                  for the output for the 'em', 'me', or 'mstep' methods
                  for the specified mixture model. 

             *  'eps': A scalar tolerance for deciding when to
                terminate computations due to computational singularity
                in covariances. Smaller values of 'eps' allow
                computations to proceed nearer to singularity. The
                default is '.Mclust\$eps'. 

                For those models with iterative M-step ("VEI", "VEV"),
                two values can be entered for 'eps', in which case the
                second value is used for determining singularity in the
                M-step. 

             *  'warnSingular': A logical value indicating whether or
                not a warning should be issued whenever a singularity
                is encountered. The default is '.Mclust\$warnSingular'.

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

     A numeric matrix whose '[i,j]'th entry is the  density of
     observation _i_ in component _j_.  The densities are not scaled by
     mixing proportions.

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

     C. Fraley and A. E. Raftery (2002a). Model-based clustering,
     discriminant analysis, and density estimation. _Journal of the
     American Statistical Association 97:611-631_.  See <URL:
     http://www.stat.washington.edu/mclust>. 

     C. Fraley and A. E. Raftery (2002b). MCLUST:Software for
     model-based clustering, density estimation and  discriminant
     analysis.  Technical Report, Department of Statistics, University
     of Washington. See <URL: http://www.stat.washington.edu/mclust>.

_S_e_e _A_l_s_o:

     'cdensE', ..., 'cdensVVV', 'dens', 'EMclust', 'mstep',
     'mclustDAtrain', 'mclustDAtest', 'mclustOptions', 'do.call'

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

     n <- 100 ## create artificial data

     set.seed(0)
     x <- rbind(matrix(rnorm(n*2), n, 2) %*% diag(c(1,9)),
                matrix(rnorm(n*2), n, 2) %*% diag(c(1,9))[,2:1])
     xclass <- c(rep(1,n),rep(2,n))
     clPairs(x, cl = xclass, sym = c("1","2")) ## display the data

     set.seed(0)
     I <- sample(1:(2*n)) ## random ordering of the data
     x <- x[I, ]
     xclass <- xclass[I]

     odd <- seq(1, 2*n, by = 2)
     oddBic <- EMclust(x[odd, ]) 
     oddSumry <- summary(oddBic, x[odd, ]) ## best parameter estimates
     names(oddSumry)

     even <- odd + 1
     temp <- cdens(modelName = oddSumry$modelName, data = x[even, ],
                   mu = oddSumry$mu, decomp = oddSumry$decomp)
     cbind(class = xclass[even], temp)

     ## alternative call 

     ## Not run: 
     temp <- do.call( "cdens", c(list(data = x[even, ]), oddSumry))
     cbind(class = xclass[even], temp)
     ## End(Not run)

