Learn R Programming

Rmixmod (version 2.0.3)

mixmodCluster: Create an instance of the [MixmodCluster] class

Description

This function computes an optimal mixture model according to the criteria furnished, and the list of model defined in [Model], using the algorithm specified in [Strategy].

Usage

mixmodCluster(data, nbCluster, dataType = NULL, models = NULL, strategy = mixmodStrategy(), criterion = "BIC", weight = NULL, knownLabels = NULL)

Arguments

data
frame containing quantitative,qualitative or heterogeneous data. Rows correspond to observations and columns correspond to variables.
nbCluster
numeric listing the number of clusters.
dataType
character. Type of data is "quantitative", "qualitative" or "composite". Set as NULL by default, type will be guessed depending on variables type.
models
a [Model] object defining the list of models to run. For quantitative data, the model "Gaussian_pk_Lk_C" is called (see mixmodGaussianModel() to specify other models). For qualitative data, the model "Binary_pk_Ekjh" is called (see mixmodMultinomialModel() to specify other models).
strategy
a [Strategy] object containing the strategy to run. Call mixmodStrategy() method by default.
criterion
list of character defining the criterion to select the best model. The best model is the one with the lowest criterion value. Possible values: "BIC", "ICL", "NEC", c("BIC", "ICL", "NEC"). Default is "BIC".
weight
numeric vector with n (number of individuals) rows. Weight is optionnal. This option is to be used when weight is associated to the data.
knownLabels
vector of size nbSample. it will be used for semi-supervised classification when labels are known. Each cell corresponds to a cluster affectation.

Value

Returns an instance of the [MixmodCluster] class. Those two attributes will contain all outputs:
results
a list of [MixmodResults] object containing all the results sorted in ascending order according to the given criterion.
bestResult
a S4 [MixmodResults] object containing the best model results.

Examples

Run this code
## A quantitative example with the famous geyser data set
  data(geyser)
  ## with default values
  mixmodCluster(geyser, nbCluster=2:6)

  ## A qualitative example with the birds data set
  data(birds)
  mixmodCluster(data=birds, nbCluster = 2:5, criterion= c("BIC","ICL","NEC"),
                model = mixmodMultinomialModel())

  ## use graphics functions
  xem <- mixmodCluster(data=geyser, nbCluster=3)
  ## Not run: 
#   plot(xem)
#   hist(xem)
#   ## End(Not run)

  ## get summary
  summary(xem)

  ## A composite example with a heterogeneous data set
  data(heterodata)
  mixmodCluster(heterodata,2)

Run the code above in your browser using DataLab