The HPCLUS Procedure

Example 5.2 Finding the Number of Clusters

You can find the number of clusters in the data set by specifying NOC=ABC in the PROC HPCLUS statement as follows:



proc hpclus data=sampsio.dmairis maxclusters=9
         NOC=ABC(B=10 minclusters=2 align=PCA criterion=FIRSTPEAK);
   input  sep: pet: ;
   ods output ABCStats=ABCStats1;
run;

These statements create three additional ODS tables, which are shown in Output 5.2.1, Output 5.2.2, and Output 5.2.4. Output 5.2.1 shows the parameters that are used in the aligned box criterion (ABC) method.

Output 5.2.1: Aligned Box Criterion Parameters

Canonical Discriminant Analysis of Iris Clusters
Plot of Canonical Variables Identified by Cluster

The HPCLUS Procedure

ABC Parameters
Minimum
Cluster
Maximum
Cluster
Reference
Distribution
Count
Alignment
Method
2910PCA


Output 5.2.2 shows the statistics that are obtained for each candidate number of clusters.

Output 5.2.2: Aligned Box Criterion Statistics

ABC Statistics
Number of
Clusters
Logarithm of
Within-Cluster SSE
GapSimulation
Adjusted
Standard
Deviation
One
Standard
Error
Adjusted
Gap
InputReference
29.631510.09500.46350.04690.4167
38.97399.32490.35100.05130.2997
48.65658.97850.32200.03320.2889
58.51468.80860.29400.05000.2440
68.26768.62170.35410.04650.3076
78.14768.54640.39880.04940.3494
88.09118.44980.35870.09060.2681
98.04168.42250.38100.10550.2754


The following statements plot the gap values:


title "ABC Statistics Plot Using Gap Values";
proc sgplot data= ABCStats1;
   xaxis type=discrete;
   series x= K y= Gap;
run;
title ' ';

Output 5.2.3 shows that the first peak value is at 4. This result is also shown in the estimated number of clusters table, which is shown in Output 5.2.4.

Output 5.2.3: Gap Values

Gap Values


Output 5.2.4: Estimated Number of Clusters

Estimated Number of Clusters
CriterionNumber of
Clusters
FIRSTPEAK7


When you use the NOC= option, the HPCLUS procedure first estimates the number of clusters, k, and then it displays the cluster analysis results with k. Output 5.2.5 shows the cluster summary table that is obtained by four clusters.

Output 5.2.5: Cluster Summary Table for Four Clusters

Cluster Summary
ClusterFrequencyDistance from Cluster Centroid
to Observation
SSEStandard
Deviation
Nearest
Cluster
Distance
to
Nearest
Cluster
Centroid
MaximumMinimumAverage
12810.69891.61555.3177974.95.9008711.9753
2128.65303.51785.9555465.56.2283411.9158
3156.58582.12293.7941242.44.020077.1324
4227.50292.58014.2624431.54.429079.9613
5278.61541.03773.7210445.94.064067.8249
6238.63851.38863.2684317.73.716357.8249
7238.17752.09604.7216577.05.008537.1324


Last updated: May 25, 2022