NAG CL Interfaceg03ehc (cluster_​hier_​dendrogram)

Settings help

CL Name Style:

1Purpose

g03ehc produces a dendrogram from the results of g03ecc.

2Specification

 #include
 void g03ehc (Nag_DendOrient orient, Integer n, const double dord[], double dmin, double dstep, Integer nsym, char ***c, NagError *fail)
The function may be called by the names: g03ehc, nag_mv_cluster_hier_dendrogram or nag_mv_dendrogram.

3Description

Hierarchical cluster analysis, as performed by g03ecc can be represented by a tree that shows at which distance the clusters merge. Such a tree is known as a dendrogram. See Everitt (1974) and Krzanowski (1990) for examples of dendrograms. A simple example is,
The end-points of the dendrogram represent the objects that have been clustered. They should be in a suitable order as given by g03ecc. Object 1 is always the first object. In the example above the height represents the distance at which the clusters merge.
The dendrogram is produced in an array of character pointers using the ordering and distances provided by g03ecc. Suitable characters are used to represent parts of the tree.
There are four possible orientations for the dendrogram. The example above has the end-points at the bottom of the diagram which will be referred to as south. If the dendrogram was the other way around with the end-points at the top of the diagram then the orientation would be north. If the end-points are at the left-hand or right-hand side of the diagram the orientation is west or east. Different symbols are used for east/west and north/south orientations.

4References

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

5Arguments

1: $\mathbf{orient}$Nag_DendOrient Input
On entry: indicates which orientation the dendrogram is to take.
${\mathbf{orient}}=\mathrm{Nag_DendNorth}$
The end-points of the dendrogram are to the north.
${\mathbf{orient}}=\mathrm{Nag_DendSouth}$
The end-points of the dendrogram are to the south.
${\mathbf{orient}}=\mathrm{Nag_DendEast}$
The end-points of the dendrogram are to the east.
${\mathbf{orient}}=\mathrm{Nag_DendWest}$
The end-points of the dendrogram are to the west.
Constraint: ${\mathbf{orient}}=\mathrm{Nag_DendNorth}$, $\mathrm{Nag_DendSouth}$, $\mathrm{Nag_DendEast}$ or $\mathrm{Nag_DendWest}$.
2: $\mathbf{n}$Integer Input
On entry: the number of objects in the cluster analysis.
Constraint: ${\mathbf{n}}\ge 2$.
3: $\mathbf{dord}\left[{\mathbf{n}}\right]$const double Input
On entry: the array dord as output by g03ecc. dord contains the distances, in dendrogram order, at which clustering takes place.
Constraint: ${\mathbf{dord}}\left[{\mathbf{n}}-1\right]\ge {\mathbf{dord}}\left[\mathit{i}-1\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}-1$.
4: $\mathbf{dmin}$double Input
On entry: the clustering distance at which the dendrogram begins.
Constraint: ${\mathbf{dmin}}\ge 0.0$.
5: $\mathbf{dstep}$double Input
On entry: the distance represented by one symbol of the dendrogram.
Constraint: ${\mathbf{dstep}}>0.0$.
6: $\mathbf{nsym}$Integer Input
On entry: the number of character positions used in the dendrogram. Hence the clustering distance at which the dendrogram terminates is given by ${\mathbf{dmin}}+{\mathbf{nsym}}×{\mathbf{dstep}}$.
Constraint: ${\mathbf{nsym}}\ge 1$.
7: $\mathbf{c}$char *** Input/Output
On entry/exit: a pointer to an array of character pointers, containing consecutive lines of the dendrogram. The memory to which c points is allocated internally.
${\mathbf{orient}}=\mathrm{Nag_DendNorth}$ or $\mathrm{Nag_DendSouth}$
The number of lines in the dendrogram is nsym.
${\mathbf{orient}}=\mathrm{Nag_DendEast}$ or $\mathrm{Nag_DendWest}$
The number of lines in the dendrogram is n.
The storage pointed to by this pointer must be freed using g03xzc.
8: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6Error Indicators and Warnings

On entry, argument orient had an illegal value.
NE_DENDROGRAM_ARRAY
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{dord}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{dord}}\left[{\mathbf{n}}-1\right]\ge {\mathbf{dord}}\left[i-1\right]$, $i=1,2,\dots ,{\mathbf{n}}-1$.
NE_INT_ARG_LT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 2$.
On entry, ${\mathbf{nsym}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{nsym}}\ge 1$.
NE_INTERNAL_ERROR
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.
NE_REAL_ARG_LE
On entry, dstep must not be less than or equal to 0.0: ${\mathbf{dstep}}=⟨\mathit{\text{value}}⟩$.
NE_REAL_ARG_LT
On entry, dmin must not be less than 0.0: ${\mathbf{dmin}}=⟨\mathit{\text{value}}⟩$.

Not applicable.

8Parallelism and Performance

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

The scale of the dendrogram is controlled by dstep. The smaller the value of dstep the greater the amount of detail that will be given. However, nsym will have to be larger to give the full dendrogram. The range of distances represented by the dendrogram is dmin to ${\mathbf{nsym}}×{\mathbf{dstep}}$. The values of dmin, dstep and nsym can thus be set so that only part of the dendrogram is produced.
The dendrogram does not include any labelling of the objects. You can print suitable labels using the ordering given by the array iord returned by g03ecc.

10Example

Data consisting of three variables on five objects are read in. Euclidean squared distances are computed using g03eac and median clustering performed by g03ecc. g03ehc is used to produce a dendrogram with orientation east and a dendrogram with orientation south. The two dendrograms are printed.
Note the use of g03xzc to free the memory allocated internally to the character array pointed to by c.

10.1Program Text

Program Text (g03ehce.c)

10.2Program Data

Program Data (g03ehce.d)

10.3Program Results

Program Results (g03ehce.r)