evalClusters {ChemoSpec}R Documentation

Evaluate or Compare the Quality of Clusters Quantitatively

Description

This function is a wrapper to two functions: intCriteria function in package clusterCrit, and NbClust in package NbClust. It can be used to quantitatively compare different clustering options.

Usage

evalClusters(
  spectra,
  pkg = "NbClust",
  hclst = NULL,
  k = NULL,
  h = NULL,
  crit = "Dunn",
  ...
)

Arguments

spectra

An object of S3 class Spectra.

pkg

Character. One of c("NbClust", "clusterCrit"). The package to use for comparing clusters.

hclst

An object of S3 class hclust. Only applies to pkg = "clusterCrit".

k

Integer. The number of groups in which to cut the tree (hclust). Only applies to pkg = "clusterCrit".

h

Numeric. The height at which to cut the tree. Either k or h must be given, with k taking precedence. See cutree. Only applies to pkg = "clusterCrit".

crit

String. A string giving the criteria to be used in evaluating the quality of the cluster. See liintCriteria. Only applies to pkg = "clusterCrit".

...

Other parameters to be passed to the functions. In particular, the default NbClust package will need some parameters. See the example.

Details

Both of the packages used here compute very similar quantities. For details, see the publication and respective vignettes. Package clusterCrit takes the approach in which you cluster in a separate step using whatever parameters you like, then the tree is cut either at a given height or in such a way as to produce a fixed number of groups. One or more indices are then computed. Then, you repeat this process with different clustering criteria, and compare. Package NbClust allows one to specify a range of possible number of clusters and a few other parameters and will return indices corresponding to each set options, which is somewhat more automated.

Value

A list giving the results, as described in intCriteria or NbClust.

Author(s)

Bryan A. Hanson (DePauw University)

References

M. Charrad et. al. "NbClust: An R Package for Determining the Relevant Number of Clusters in a Data Set." J. Stat. Soft. vol. 61 no. 6 October 2014.

See Also

hclust for the underlying base function. hcaSpectra for HCA analysis of a Spectra object. hcaScores for HCA analysis of PCA scores from a Spectra object. Additional documentation at https://bryanhanson.github.io/ChemoSpec/

Examples


## Not run: 
data(metMUD2)

# Using clusterCrit
res1 <- hcaSpectra(metMUD2) # default clustering and distance methods
res2 <- hcaSpectra(metMUD2, d.method = "cosine")
# The return value from hcaSpectra is a list with hclust as the first element.
crit1 <- evalClusters(metMUD2, pkg = "clusterCrit", hclst = res1[[1]], k = 2)
crit2 <- evalClusters(metMUD2, pkg = "clusterCrit", hclst = res2[[1]], k = 2)
# crit1 and crit2 can now be compared.

# Using NbClust
res3 <- evalClusters(metMUD2, min.nc = 2, max.nc = 5, method = "average", index = "kl")

## End(Not run)


[Package ChemoSpec version 6.0.1 Index]