The FASTCLUS Procedure

Example 39.1 Fisher’s Iris Data

(View the complete code for this example.)

The iris data published by Fisher (1936) have been widely used for examples in discriminant analysis and cluster analysis. The sepal length, sepal width, petal length, and petal width are measured in millimeters on 50 iris specimens from each of three species, Iris setosa, I. versicolor, and I. virginica. Mezzich and Solomon (1980) discuss a variety of cluster analyses of the iris data.

In this example, the FASTCLUS procedure is used to find two and then three clusters. In the following code, an output data set is created, and PROC FREQ is invoked to compare the clusters with the species classification. See Output 39.1.1 and Output 39.1.2 for these results.

For three clusters, you can use the CANDISC procedure to compute canonical variables for plotting the clusters. See Output 39.1.3 and Output 39.1.4 for the results.

proc format;
   value specname
      1='Setosa    '
      2='Versicolor'
      3='Virginica ';
run;

data iris;
   title 'Fisher (1936) Iris Data';
   input SepalLength SepalWidth PetalLength PetalWidth Species @@;
   format Species specname.;
   label SepalLength='Sepal Length in mm.'
         SepalWidth ='Sepal Width in mm.'
         PetalLength='Petal Length in mm.'
         PetalWidth ='Petal Width in mm.';
   datalines;
50 33 14 02 1 64 28 56 22 3 65 28 46 15 2 67 31 56 24 3
63 28 51 15 3 46 34 14 03 1 69 31 51 23 3 62 22 45 15 2
59 32 48 18 2 46 36 10 02 1 61 30 46 14 2 60 27 51 16 2
65 30 52 20 3 56 25 39 11 2 65 30 55 18 3 58 27 51 19 3
68 32 59 23 3 51 33 17 05 1 57 28 45 13 2 62 34 54 23 3
77 38 67 22 3 63 33 47 16 2 67 33 57 25 3 76 30 66 21 3
49 25 45 17 3 55 35 13 02 1 67 30 52 23 3 70 32 47 14 2

   ... more lines ...   

55 23 40 13 2 66 30 44 14 2 68 28 48 14 2 54 34 17 02 1
51 37 15 04 1 52 35 15 02 1 58 28 51 24 3 67 30 50 17 2
63 33 60 25 3 53 37 15 02 1
;
proc fastclus data=iris maxc=2 maxiter=10 out=clus;
   var SepalLength SepalWidth PetalLength PetalWidth;
run;

proc freq;
   tables cluster*species;
run;

proc fastclus data=iris maxc=3 maxiter=10 out=clus;
   var SepalLength SepalWidth PetalLength PetalWidth;
run;

proc freq;
   tables cluster*Species;
run;

proc candisc anova out=can;
   class cluster;
   var SepalLength SepalWidth PetalLength PetalWidth;
   title2 'Canonical Discriminant Analysis of Iris Clusters';
run;

proc sgplot data=Can;
   scatter y=Can2 x=Can1 / group=Cluster;
   title2 'Plot of Canonical Variables Identified by Cluster';
run;

Output 39.1.1: Fisher’s Iris Data: PROC FASTCLUS with MAXC=2 and PROC FREQ

Fisher (1936) Iris Data

The FASTCLUS Procedure
Replace=FULL Radius=0 Maxclusters=2 Maxiter=10 Converge=0.02

Initial Seeds
ClusterSepalLengthSepalWidthPetalLengthPetalWidth
143.0000000030.0000000011.000000001.00000000
277.0000000026.0000000069.0000000023.00000000

Minimum Distance Between Initial Seeds =70.85196

Iteration History
IterationCriterionRelative Change in Cluster
Seeds
1 2
111.06380.19040.3163
25.37800.05960.0264
35.07180.01740.00766

Convergence criterion is satisfied.

Criterion Based on Final Seeds =5.0417

Cluster Summary
ClusterFrequencyRMS Std DeviationMaximum Distance
from Seed
to Observation
Radius
Exceeded
Nearest ClusterDistance Between
Cluster Centroids
1533.705021.1621 239.2879
2975.677924.6430 139.2879

Statistics for Variables
VariableTotal STDWithin STDR-SquareRSQ/(1-RSQ)
SepalLength8.280665.493130.5628961.287784
SepalWidth4.358663.703930.2827100.394137
PetalLength17.652986.803310.8524705.778291
PetalWidth7.622383.572000.7818683.584390
OVER-ALL10.692245.072910.7764103.472463

Pseudo F Statistic =513.92

Approximate Expected Over-All R-Squared =0.51539

Cubic Clustering Criterion =14.806


WARNING: The two values above are invalid for correlated variables.

Cluster Means
ClusterSepalLengthSepalWidthPetalLengthPetalWidth
150.0566037733.6981132115.603773582.90566038
263.0103092828.8659793849.5876288716.95876289

Cluster Standard Deviations
ClusterSepalLengthSepalWidthPetalLengthPetalWidth
13.4273509304.3966110454.4042794862.105525249
26.3368874553.2679914387.8005776734.155612484

Fisher (1936) Iris Data

The FREQ Procedure

Frequency
Percent
Row Pct
Col Pct
Table of CLUSTER by Species
CLUSTER(Cluster)Species
SetosaVersicolorVirginicaTotal
1
50
33.33
94.34
100.00
3
2.00
5.66
6.00
0
0.00
0.00
0.00
53
35.33
 
 
2
0
0.00
0.00
0.00
47
31.33
48.45
94.00
50
33.33
51.55
100.00
97
64.67
 
 
Total
50
33.33
50
33.33
50
33.33
150
100.00


Output 39.1.2: Fisher’s Iris Data: PROC FASTCLUS with MAXC=3 and PROC FREQ

Fisher (1936) Iris Data

The FASTCLUS Procedure
Replace=FULL Radius=0 Maxclusters=3 Maxiter=10 Converge=0.02

Initial Seeds
ClusterSepalLengthSepalWidthPetalLengthPetalWidth
158.0000000040.0000000012.000000002.00000000
277.0000000038.0000000067.0000000022.00000000
349.0000000025.0000000045.0000000017.00000000

Minimum Distance Between Initial Seeds =38.23611

Iteration History
IterationCriterionRelative Change in Cluster Seeds
1 2 3
16.75910.26520.32050.2985
23.709700.04590.0317
33.642700.01820.0124

Convergence criterion is satisfied.

Criterion Based on Final Seeds =3.6289

Cluster Summary
ClusterFrequencyRMS Std DeviationMaximum Distance
from Seed
to Observation
Radius
Exceeded
Nearest ClusterDistance Between
Cluster Centroids
1502.780312.4803 333.5693
2384.016814.9736 317.9718
3624.039816.9272 217.9718

Statistics for Variables
VariableTotal STDWithin STDR-SquareRSQ/(1-RSQ)
SepalLength8.280664.394880.7220962.598359
SepalWidth4.358663.248160.4521020.825156
PetalLength17.652984.214310.94377316.784895
PetalWidth7.622382.452440.8978728.791618
OVER-ALL10.692243.661980.8842757.641194

Pseudo F Statistic =561.63

Approximate Expected Over-All R-Squared =0.62728

Cubic Clustering Criterion =25.021


WARNING: The two values above are invalid for correlated variables.

Cluster Means
ClusterSepalLengthSepalWidthPetalLengthPetalWidth
150.0600000034.2800000014.620000002.46000000
268.5000000030.7368421157.4210526320.71052632
359.0161290327.4838709743.9354838714.33870968

Cluster Standard Deviations
ClusterSepalLengthSepalWidthPetalLengthPetalWidth
13.5248968723.7906436911.7366399651.053855894
24.9415502552.9009244614.8858957462.798724562
34.6641005512.9628405485.0889496732.974997167

Fisher (1936) Iris Data

The FREQ Procedure

Frequency
Percent
Row Pct
Col Pct
Table of CLUSTER by Species
CLUSTER(Cluster)Species
SetosaVersicolorVirginicaTotal
1
50
33.33
100.00
100.00
0
0.00
0.00
0.00
0
0.00
0.00
0.00
50
33.33
 
 
2
0
0.00
0.00
0.00
2
1.33
5.26
4.00
36
24.00
94.74
72.00
38
25.33
 
 
3
0
0.00
0.00
0.00
48
32.00
77.42
96.00
14
9.33
22.58
28.00
62
41.33
 
 
Total
50
33.33
50
33.33
50
33.33
150
100.00


Output 39.1.3: Fisher’s Iris Data using PROC CANDISC

Fisher (1936) Iris Data
Canonical Discriminant Analysis of Iris Clusters

The CANDISC Procedure

Total Sample Size150DF Total149
Variables4DF Within Classes147
Classes3DF Between Classes2

Number of Observations Read150
Number of Observations Used150

Class Level Information
CLUSTERVariable
Name
FrequencyWeightProportion
1_15050.00000.333333
2_23838.00000.253333
3_36262.00000.413333

Fisher (1936) Iris Data
Canonical Discriminant Analysis of Iris Clusters

The CANDISC Procedure

Univariate Test Statistics
F Statistics, Num DF=2, Den DF=147
VariableLabelTotal
Standard
Deviation
Pooled
Standard
Deviation
Between
Standard
Deviation
R-SquareR-Square
/ (1-RSq)
F ValuePr > F
SepalLengthSepal Length in mm.8.28074.39498.58930.72212.5984190.98<.0001
SepalWidthSepal Width in mm.4.35873.24823.57740.45210.825260.65<.0001
PetalLengthPetal Length in mm.17.65304.214320.93360.943816.78491233.69<.0001
PetalWidthPetal Width in mm.7.62242.45248.81640.89798.7916646.18<.0001

Average R-Square
Unweighted0.7539604
Weighted by Variance0.8842753

Multivariate Statistics and F Approximations
S=2 M=0.5 N=71
StatisticValueF ValueNum DFDen DFPr > F
Wilks' Lambda0.03222337164.558288<.0001
Pillai's Trace1.2566961261.298290<.0001
Hotelling-Lawley Trace21.06722883377.668203.4<.0001
Roy's Greatest Root20.63266809747.934145<.0001
NOTE: F Statistic for Roy's Greatest Root is an upper bound.
NOTE: F Statistic for Wilks' Lambda is exact.

Fisher (1936) Iris Data
Canonical Discriminant Analysis of Iris Clusters

The CANDISC Procedure

 Canonical
Correlation
Adjusted
Canonical
Correlation
Approximate
Standard
Error
Squared
Canonical
Correlation
Eigenvalues of Inv(E)*H
= CanRsq/(1-CanRsq)
Test of H0: The canonical correlations in the current row and all that follow are zero
 EigenvalueDifferenceProportionCumulativeLikelihood
Ratio
Approximate
F Value
Num DFDen DFPr > F
10.9766130.9761230.0037870.95377420.632720.19810.97940.97940.03222337164.558288<.0001
20.5503840.5433540.0571070.3029230.4346 0.02061.00000.6970774921.003145<.0001

Fisher (1936) Iris Data
Canonical Discriminant Analysis of Iris Clusters

The CANDISC Procedure

Total Canonical Structure
VariableLabelCan1Can2
SepalLengthSepal Length in mm.0.8319650.452137
SepalWidthSepal Width in mm.-0.5150820.810630
PetalLengthPetal Length in mm.0.9935200.087514
PetalWidthPetal Width in mm.0.9663250.154745

Between Canonical Structure
VariableLabelCan1Can2
SepalLengthSepal Length in mm.0.9561600.292846
SepalWidthSepal Width in mm.-0.7481360.663545
PetalLengthPetal Length in mm.0.9987700.049580
PetalWidthPetal Width in mm.0.9959520.089883

Pooled Within Canonical Structure
VariableLabelCan1Can2
SepalLengthSepal Length in mm.0.3393140.716082
SepalWidthSepal Width in mm.-0.1496140.914351
PetalLengthPetal Length in mm.0.9008390.308136
PetalWidthPetal Width in mm.0.6501230.404282

Fisher (1936) Iris Data
Canonical Discriminant Analysis of Iris Clusters

The CANDISC Procedure

Total-Sample Standardized Canonical Coefficients
VariableLabelCan1Can2
SepalLengthSepal Length in mm.0.0477473411.021487262
SepalWidthSepal Width in mm.-0.5775692440.864455153
PetalLengthPetal Length in mm.3.341309573-1.283043758
PetalWidthPetal Width in mm.0.9964511440.900476563

Pooled Within-Class Standardized Canonical Coefficients
VariableLabelCan1Can2
SepalLengthSepal Length in mm.0.02534144870.5421446856
SepalWidthSepal Width in mm.-.43041612580.6442092294
PetalLengthPetal Length in mm.0.7976741592-.3063023132
PetalWidthPetal Width in mm.0.32059980340.2897207865

Raw Canonical Coefficients
VariableLabelCan1Can2
SepalLengthSepal Length in mm.0.00576612650.1233581748
SepalWidthSepal Width in mm.-.13251064940.1983303556
PetalLengthPetal Length in mm.0.1892773419-.0726814163
PetalWidthPetal Width in mm.0.13072709270.1181359305

Class Means on Canonical Variables
CLUSTERCan1Can2
1-6.1315272270.244761516
24.9314140180.861972277
31.922300462-0.725693908


Output 39.1.4: Plot of Fisher’s Iris Data using PROC CANDISC

Plot of Fisher’s Iris Data using PROC CANDISC