NAG CL Interface
g03ejc (cluster_​hier_​indicator)

Settings help

CL Name Style:

1 Purpose

g03ejc computes a cluster indicator variable from the results of g03ecc.

2 Specification

#include <nag.h>
void  g03ejc (Integer n, const double cd[], const Integer iord[], const double dord[], Integer *k, double *dlevel, Integer ic[], NagError *fail)
The function may be called by the names: g03ejc, nag_mv_cluster_hier_indicator or nag_mv_cluster_indicator.

3 Description

Given a distance or dissimilarity matrix for n objects, cluster analysis aims to group the n objects into a number of more or less homogeneous groups or clusters. With agglomerative clustering methods (see g03ecc), a hierarchical tree is produced by starting with n clusters each with a single object and then at each of n-1 stages, merging two clusters to form a larger cluster until all objects are in a single cluster. g03ejc takes the information from the tree and produces the clusters that exist at a given distance. This is equivalent to taking the dendrogram (see g03ehc) and drawing a line across at a given distance to produce clusters.
As an alternative to giving the distance at which clusters are required, you can specify the number of clusters required and g03ejc will compute the corresponding distance. However, it may not be possible to compute the number of clusters required due to ties in the distance matrix.
If there are k clusters then the indicator variable will assign a value between 1 and k to each object to indicate to which cluster it belongs. Object 1 always belongs to cluster 1.

4 References

Everitt B S (1974) Cluster Analysis Heinemann
Krzanowski W J (1990) Principles of Multivariate Analysis Oxford University Press

5 Arguments

1: n Integer Input
On entry: the number of objects, n .
Constraint: n2 .
2: cd[n-1] const double Input
On entry: the clustering distances in increasing order as returned by g03ecc.
Constraint: cd[i] cd[i-1] , for i=1,2,,n-2.
3: iord[n] const Integer Input
On entry: the objects in the dendrogram order as returned by g03ecc.
4: dord[n] const double Input
On entry: the clustering distances corresponding to the order in iord.
5: k Integer * Input/Output
On entry: indicates if a specified number of clusters is required.
g03ejc will attempt to find k clusters.
g03ejc will find the clusters based on the distance given in dlevel.
Constraint: kn .
On exit: the number of clusters produced, k .
6: dlevel double * Input/Output
On entry: if k0 , then dlevel must contain the distance at which clusters are produced. Otherwise dlevel need not be set.
Constraint: if k0 , dlevel>0.0 .
On exit: if k>0 on entry, then dlevel contains the distance at which the required number of clusters are found. Otherwise dlevel remains unchanged.
7: ic[n] Integer Output
On exit: ic[i-1] indicates to which of k clusters the i th object belongs, for i=1,2,,n.
8: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

On entry, k=value while n=value . These arguments must satisfy kn .
The precise number of clusters requested is not possible because of
tied clustering distances. The actual number of clusters produced is value.
Arrays cd and dord are not compatible.
On entry, n=value.
Constraint: n2.
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
The sequence cd is not increasing:
cd[value] = value, cd[value] = value.
On entry, dlevel=value , k=value .
Constraint: k0 and dlevel>0.0 .
On exit, k=value , n=value .
Trivial solution returned.
On exit, k=1 .
Trivial solution returned.
On entry, dlevel=value , cd[value] = value.
Trivial solution returned.

7 Accuracy

The accuracy will depend upon the accuracy of the distances in cd and dord (see g03ecc).

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
g03ejc is not threaded in any implementation.

9 Further Comments

A fixed number of clusters can be found using the non-hierarchical method used in g03efc.

10 Example

Data consisting of three variables on five objects are input. Euclidean squared distances are computed using g03eac and median clustering performed using g03ecc. A dendrogram is produced by g03ehc and printed. g03ejc finds two clusters and the results are printed.

10.1 Program Text

Program Text (g03ejce.c)

10.2 Program Data

Program Data (g03ejce.d)

10.3 Program Results

Program Results (g03ejce.r)