nag_mv_dendrogram (g03ehc) produces a dendrogram from the results of
nag_mv_hierar_cluster_analysis (g03ecc).
Hierarchical cluster analysis, as performed by
nag_mv_hierar_cluster_analysis (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
nag_mv_hierar_cluster_analysis (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
nag_mv_hierar_cluster_analysis (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 lefthand or righthand side of the diagram the orientation is west or east. Different symbols are used for east/west and north/south orientations.
 1:
orient – Nag_DendOrientInput
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:
n – IntegerInput
On entry:
the number of objects in the cluster analysis.
Constraint:
${\mathbf{n}}>2$.
 3:
dord[n] – const doubleInput
On entry: the array
dord as output by
nag_mv_hierar_cluster_analysis (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:
dmin – doubleInput
On entry: the clustering distance at which the dendrogram begins.
Constraint:
${\mathbf{dmin}}\ge 0.0$.
 5:
dstep – doubleInput
On entry: the distance represented by one symbol of the dendrogram.
Constraint:
${\mathbf{dstep}}>0.0$.
 6:
nsym – IntegerInput
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}}\times {\mathbf{dstep}}$.
Constraint:
${\mathbf{nsym}}\ge 1$.
 7:
c – char ***Output

On 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
nag_mv_dend_free (g03xzc).
 8:
fail – NagError *Input/Output

The NAG error argument (see
Section 3.6 in the Essential Introduction).
 NE_BAD_PARAM
On entry, argument
orient had an illegal value.
 NE_DENDROGRAM_ARRAY
On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$, ${\mathbf{dord}}\left[\u2329\mathit{\text{value}}\u232a\right]=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{dord}}\left[{\mathbf{n}}1\right]\ge {\mathbf{dord}}\left[i1\right]$, $i=1,2,\dots ,{\mathbf{n}}1$.
 NE_INT_ARG_LT
On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{n}}\ge 2$.
On entry, ${\mathbf{nsym}}=\u2329\mathit{\text{value}}\u232a$.
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, ${\mathbf{dstep}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{dstep}}>0.0$
 NE_REAL_ARG_LT
On entry, ${\mathbf{dmin}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{dmin}}\ge 0.0$.
Not applicable.
The scale of the dendrogram is controlled by
dstep. The smaller the value
dstep is, the greater the amount of detail that will be given but
nsym will have to be larger to give the full dendrogram. The range of distances represented by the dendrogram is
dmin to
${\mathbf{nsym}}\times {\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
nag_mv_hierar_cluster_analysis (g03ecc).
Data consisting of three variables on five objects are read in. Euclidean squared distances are computed using
nag_mv_distance_mat (g03eac) and median clustering performed by
nag_mv_hierar_cluster_analysis (g03ecc). nag_mv_dendrogram (g03ehc) is used to produce a dendrogram with orientation east and a dendrogram with orientation south. The two dendrograms are printed.