haclust
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
Contents
haclust
Hierarchical-agglomerative cluster analysis.
Usage:
haclust(d, m)
haclust(h, c)
Parameters:
- d
- A dissimilarity or distance matrix. For N data points this is a NxN matrix (e.g. created using the
EVALfunction dist).
- m
- The cluster method:
0Single Linkage
1Complete Linkage
2Weighted Average Linkage
3Average Linkage
4Median
5Centroid
6Ward
- h
- A cluster hierarchy.
- c
- The number of clusters.
Result:
When using the parameters d and m, the result is a cluster hierarchy. This is a 3x(N-1) table containing the merged cluster pairs and the agglomeration niveaus.
The parameters h and c cause haclust to create a partition, which is a 1xN table containing the group indices.
Examples:
A simple demonstration of haclust usage.
[macro haclust_example]
// create bivariate input data
#datatable := new table * 2 /p num:x num:y
$#datatable[*,0] := '1;2;1;3;4.5'
$#datatable[*,1] := '1;0.5;4;2;4'
// compute distance matrix
#disttable := eval dist($#datatable)
// cluster analysis methods:
// 0 (SL), 1 (CL), 2 (WAL), 3 (AL), 4 (M), 5 (C), 6 (W)
#method := 6 // Ward
// nr of clusters
#nclusters := 2
// compute hierarchy and partition
#hierarchy := eval haclust($#disttable,$#method)
#partition := eval haclust($#hierarchy,$#nclusters)
// show results
showitem $#hierarchy
showitem $#partition
exit