hclust2(d = NULL, objects = NULL, thresholdGini = 0.3,
useVpTree = FALSE, ...)dist,
NULL, or a single string, see belowNULL, numeric matrix, a list, or a character vectorhclust, see hclust,
with additional components:
stats- performance statisticscontrol- internal tuning parameters usedTo overcome its limitations, in (Gagolewski, Bartoszuk, Cena, 2016) we proposed a new hierarchical clustering linkage criterion. Namely, our algorithm links two clusters in such a way that a chosen economic inequity measure (here, the Gini index) of the cluster sizes does not increase drastically above a given threshold. The benchmarks indicate a high practical usefulness of the introduced method: it most often outperforms the Ward or average linkage in terms of the clustering quality while retaining the single linkage speed. The algorithm can be run in parallel (via OpenMP) on multiple threads to speed up its execution further on. Its memory overhead is small: there is no need to precompute the complete distance matrix to perform the computations in order to obtain a desired clustering.
For compatibility with hclust, d may be an object
of class dist. In such a case, the objects
argument is ignored. Note that such an object requires ca. 8n(n-1)/2
bytes of computer's memory, where n is the number of objects to cluster,
and therefore this setting can be used to analyse data sets of sizes
up to about 10,000-50,000.
If objects is a character vector or a list, then d
should be a single string, one of: levenshtein (or NULL),
hamming, dinu (Dinu, Sgarro, 2006),
or euclinf (Cena et al., 2015).
Note that the list must consist
either of integer or of numeric vectors only (depending on the dissimilarity
measure of choice). On the other hand, each string must be in ASCII,
but you can always convert it to UTF-32 with
stri_enc_toutf32.
Otherwise, if objects is a numeric matrix (here, each row
denotes a distinct observation), then d should be
a single string, one of: euclidean_squared (or NULL),
euclidean (which yields the same results as euclidean_squared)
manhattan, maximum, or hamming.
If useVpTree is FALSE, then the dissimilarity measure
of choice is guaranteed to be computed for each unique pair of objects
only once.
Dinu L.P., Sgarro A., A Low-complexity Distance for DNA Strings, Fundamenta Informaticae 73(3), 2006, pp. 361-372.
Gagolewski M., Bartoszuk M., Cena A., Genie: A new, fast, and outlier-resistant hierarchical clustering algorithm, 2016, (submitted paper)
library(datasets)
data(iris)
h <- hclust2(objects=as.matrix(iris[,2:3]), thresholdGini=0.2)
plot(iris[,2], iris[,3], col=cutree(h, 3), pch=as.integer(iris[,5]))Run the code above in your browser using DataLab