Programmer Guide/Command Reference/EVAL/haclust: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| Line 22: | Line 22: | ||
|6 ||Ward | |6 ||Ward | ||
|} | |} | ||
;Result 1: The result is a cluster hierarchy. This is a 3x(N-1) table containing the merged cluster pairs and the agglomeration niveaus. | ;Result 1: The result is a cluster hierarchy table ''htable''. This is a 3x(N-1) table containing the merged cluster pairs and the agglomeration niveaus. | ||
---- | ---- | ||
;Usage 2:<code>haclust(<var> | ;Usage 2:<code>haclust(<var>htable</var>, <var>nclust</var>)</code> ... create partition table: | ||
: | ;Usage 3:<code>haclust(<var>ptable</var>, <var>iclust</var>)</code> ... extract cluster data: | ||
:For a detailed description of '''Usage 2''' and '''Usage 3''' and the format of the hierarchy ''htable'' and the partition table ''ptable'' see [[../modclust|modclust]]. | |||
---- | ---- | ||
;See also: [[../modclust|modclust]] | ;See also: [[../modclust|modclust]] | ||
Revision as of 06:37, 21 April 2011
Hierarchical-agglomerative cluster analysis.
- Usage 1
haclust(d, m)- d
- A dissimilarity or distance matrix. For N data points this is a NxN matrix (e.g. created using the function dist)
- m
- The cluster method:
m method 0 Single Linkage 1 Complete Linkage 2 Weighted Average Linkage 3 Average Linkage 4 Median 5 Centroid 6 Ward
- Result 1
- The result is a cluster hierarchy table htable. This is a 3x(N-1) table containing the merged cluster pairs and the agglomeration niveaus.
- Usage 2
haclust(htable, nclust)... create partition table:- Usage 3
haclust(ptable, iclust)... extract cluster data:- For a detailed description of Usage 2 and Usage 3 and the format of the hierarchy htable and the partition table ptable see modclust.
- See also
- modclust
Example:
[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