Chapter Contents |
Previous |
Next |
The CANDISC Procedure |
proc format; value specfmt 1='Bream' 2='Roach' 3='Whitefish' 4='Parkki' 5='Perch' 6='Pike' 7='Smelt'; data fish (drop=HtPct WidthPct); title 'Fish Measurement Data'; input Species Weight Length1 Length2 Length3 HtPct WidthPct @@; Height=HtPct*Length3/100; Width=WidthPct*Length3/100; format Species specfmt.; symbol = put(Species, specfmt2.); datalines; 1 242.0 23.2 25.4 30.0 38.4 13.4 1 290.0 24.0 26.3 31.2 40.0 13.8 1 340.0 23.9 26.5 31.1 39.8 15.1 1 363.0 26.3 29.0 33.5 38.0 13.3 ...[155 more records] ;
The following program uses PROC CANDISC to find the three canonical
variables that best separate the species of fish in the fish data and
creates the output data set outcan. The NCAN= option is used to
request that only the first three canonical variables are displayed. The
%PLOTIT macro is invoked to create a plot of the first two canonical
variables. See Appendix B, "Using the %PLOTIT Macro," for more information on the %PLOTIT macro.
proc candisc data=fish ncan=3 out=outcan; class Species; var Weight Length1 Length2 Length3 Height Width; run; %plotit(data=outcan, plotvars=Can2 Can1, labelvar=_blank_, symvar=symbol, typevar=symbol, symsize=1, symlen=4, tsize=1.5, exttypes=symbol, ls=100, plotopts=vaxis=-5 to 15 by 5, vtoh=, extend=close);
PROC CANDISC begins by displaying summary information about the variables in the analysis. This information includes the number of observations, the number of quantitative variables in the analysis (specified with the VAR statement), and the number of classes in the classification variable (specified with the CLASS statement). The frequency of each class is also displayed.
PROC CANDISC performs a multivariate one-way analysis of variance (one-way MANOVA) and provides four multivariate tests of the hypothesis that the class mean vectors are equal. These tests, shown in Figure 21.2, indicate that not all of the mean vectors are equal (p<.0001).
|
The first canonical correlation is the greatest possible multiple correlation with the classes that can be achieved using a linear combination of the quantitative variables. The first canonical correlation, displayed in Figure 21.3, is 0.987463.
|
A likelihood ratio test is displayed of the hypothesis that the current canonical correlation and all smaller ones are zero. The first line is equivalent to Wilks' Lambda multivariate test.
The first canonical variable, Can1, shows that the linear combination of the centered variables Can1=-0.0006×Weight - 0.33×Length1 - 2.49×Length2 + 2.60×Length3 + 1.12×Height - 1.45×Width separates the species most effectively (see Figure 21.4).
|
PROC CANDISC computes the means of the canonical variables for each class. The first canonical variable is the linear combination of the variables Weight, Length1, Length2, Length3, Height, and Width that provides the greatest difference (in terms of a univariate F-test) between the class means. The second canonical variable provides the greatest difference between class means while being uncorrelated with the first canonical variable.
|
A plot of the first two canonical variables (Figure 21.6) shows that Can1 discriminates between three groups: 1) bream; 2) whitefish, roach, and parkki; and 3) smelt, pike, and perch. Can2 best discriminates between pike and the other species.
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.