Home   >   User Resources   >   Online Help   >   apaClustering.kMeans.Bisecting.FromDistances
 

 

Function index Version 3.0.0

apaClustering.kMeans.Bisecting.FromDistances(Distances, nClusters, nMultiStarts, DoShowStructureOtherwiseFinalGrouping)

Excel=apaClustering.kMeans.Bisecting.FromDistances(Distances, nClusters, nMultiStarts, DoShowStructureOtherwiseFinalGrouping)

Result

Statistical classification with the bisecting k-means algorithm, starting from a distance matrix instead of a data matrix. Returns an n x 1 vector with the cluster label of each object, numbered from 0 to nClusters - 1.

Syntax

Distances: n x n symmetric distance matrix with zero diagonal and non-negative entries, e.g. from apaDistances.Euclidian

nClusters: number of clusters, integer between 1 and n

nMultiStarts: optional; number of k-means++ starts per bisection, integer, at least 1; the split with the lowest within-cluster sum of squares is used; default: 10

DoShowStructureOtherwiseFinalGrouping: optional; TRUE: n x nClusters matrix showing all levels of the bisection, column c containing the grouping into c clusters; FALSE: n x 1 vector with the final grouping; default: FALSE

Algorithm

The algorithm starts with all objects in one cluster and repeatedly splits the cluster with the largest within-cluster sum of squares into two with k-means, until nClusters clusters are formed. Because k-means only needs squared distances between objects and cluster centroids, the procedure is carried out on the distance matrix alone: the squared distance of object i to the centroid of cluster C is the mean of d(i,j)² over j in C minus half the mean of d(j,l)² over all pairs j, l in C, and the within-cluster sum of squares of C is the sum of d(j,l)² over all pairs j < l in C divided by the size of C.

Remarks

If Distances contains the Euclidean distances between the rows of a data matrix, the function returns the same cluster labels as apaClustering.kMeans.Bisecting applied to that data matrix. Other distance measures can be used as well; the result is then the bisecting k-means classification of the objects embedded with these distances. The random starts use a fixed seed, so results are reproducible.

With DoShowStructureOtherwiseFinalGrouping = TRUE, the first column contains 0 for all objects and each further column is the grouping after one more split: one cluster of the previous column is divided in two, the objects of the other clusters keep their labels and the new cluster gets the label c - 1. The last column equals the final grouping. Columns for levels that cannot be reached because no cluster with more than one object is left are shown as #N/A.