Learn R Programming

ChemoSpec (version 4.2.8)

evalClusters: 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

Value

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

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.

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.

https://github.com/bryanhanson/ChemoSpec

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. plotHCA for the plotting function in ChemoSpec.

Examples

Run this code
# These are a little slow for CRAN checking
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")

Run the code above in your browser using DataLab