The KCLUS Procedure
Example 9.2 Finding the Number of Clusters
This example uses the same data table that is loaded into your CAS session in Example 9.1.
You can find the number of clusters in the data table by specifying NOC=ABC in the PROC KCLUS statement as follows:
data mycas.iris;
set sashelp.iris;
run;
proc kclus data=mycas.iris maxclusters=9 seed=1234
NOC=ABC(B=10 minclusters=2 align=PCA criterion=FIRSTPEAK);
input SepalLength SepalWidth PetalLength PetalWidth;
ods output ABCStats=ABCStats1;
run;
PROC KCLUS generates several ODS tables, some of which are shown in Output 9.2.1 through Output 9.2.4.
Output 9.2.1 shows the parameters that are used in the aligned box criterion (ABC) method.
Output 9.2.1: Aligned Box Criterion Parameters
| ABC Parameters | |||
|---|---|---|---|
| Minimum Cluster | Maximum Cluster | Reference Distribution Count | Alignment Method |
| 2 | 9 | 10 | PCA |
Output 9.2.2 shows the statistics that are obtained for each candidate number of clusters.
Output 9.2.2: Aligned Box Criterion Statistics
| ABC Statistics | |||||
|---|---|---|---|---|---|
| Number of Clusters | Logarithm of Within-Cluster SSE | Gap | Simulation Adjusted Standard Deviation | One Standard Error Adjusted Gap | |
| Input | Reference | ||||
| 2 | 9.6313 | 10.3271 | 0.6957 | 0.0304 | 0.6654 |
| 3 | 8.9727 | 9.4646 | 0.4919 | 0.0386 | 0.4533 |
| 4 | 8.6549 | 9.0401 | 0.3852 | 0.0370 | 0.3482 |
| 5 | 8.5167 | 7.6998 | -0.8169 | 0.0738 | -0.8907 |
| 6 | 8.5023 | 7.3959 | -1.1064 | 0.0840 | -1.1904 |
| 7 | 8.2512 | 6.9015 | -1.3497 | 0.0635 | -1.4132 |
| 8 | 8.1193 | 8.1228 | 0.00350 | 0.0497 | -0.0462 |
| 9 | 8.0772 | 8.3575 | 0.2804 | 0.0508 | 0.2296 |
Output 9.2.3: Estimated Number of Clusters
| Estimated Number of Clusters | |
|---|---|
| Criterion | Number of Clusters |
| FirstPeak | 2 |
Output 9.2.4: Cluster Summary Table for Each Cluster
| Cluster Summary for Interval Variables | ||||||||
|---|---|---|---|---|---|---|---|---|
| Cluster | Frequency | Distance from Cluster Centroid to Observation | SSE | Standard Deviation | Nearest Cluster | Distance to Nearest Cluster Centroid | ||
| Minimum | Maximum | Average | ||||||
| 1 | 97 | 2.2162 | 24.8448 | 10.0346 | 12379.6 | 11.2971 | 2 | 39.2879 |
| 2 | 53 | 1.1310 | 21.6197 | 5.8492 | 2855.2 | 7.3397 | 1 | 39.2879 |
When you use the NOC= option, the KCLUS procedure first estimates the number of clusters, k, and then it displays the cluster analysis results for each of the k clusters as shown in Output 9.2.4.