The STEPDISC Procedure

Example 110.1 Performing a Stepwise Discriminant Analysis

(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. The iris data set is available from the Sashelp library.

A stepwise discriminant analysis is performed by using stepwise selection.

In the PROC STEPDISC statement, the BSSCP and TSSCP options display the between-class SSCP matrix and the total-sample corrected SSCP matrix. By default, the significance level of an F test from an analysis of covariance is used as the selection criterion. The variable under consideration is the dependent variable, and the variables already chosen act as covariates. The following SAS statements produce Output 110.1.1 through Output 110.1.8:

title 'Fisher (1936) Iris Data';

%let _stdvar = ;
proc stepdisc data=sashelp.iris bsscp tsscp;
   class Species;
   var SepalLength SepalWidth PetalLength PetalWidth;
run;

Output 110.1.1: Iris Data: Summary Information

Fisher (1936) Iris Data

The STEPDISC Procedure

The Method for Selecting Variables is STEPWISE
Total Sample Size150Variable(s) in the Analysis4
Class Levels3Variable(s) Will Be Included0
  Significance Level to Enter0.15
  Significance Level to Stay0.15

Number of Observations Read150
Number of Observations Used150

Class Level Information
SpeciesVariable
Name
FrequencyWeightProportion
SetosaSetosa5050.00000.333333
VersicolorVersicolor5050.00000.333333
VirginicaVirginica5050.00000.333333


Output 110.1.2: Iris Data: Between-Class and Total-Sample SSCP Matrices

Fisher (1936) Iris Data

The STEPDISC Procedure

Between-Class SSCP Matrix
VariableLabelSepalLengthSepalWidthPetalLengthPetalWidth
SepalLengthSepal Length (mm)6321.21333-1995.2666716524.840007127.93333
SepalWidthSepal Width (mm)-1995.266671134.49333-5723.96000-2293.26667
PetalLengthPetal Length (mm)16524.84000-5723.9600043710.2800018677.40000
PetalWidthPetal Width (mm)7127.93333-2293.2666718677.400008041.33333

Total-Sample SSCP Matrix
VariableLabelSepalLengthSepalWidthPetalLengthPetalWidth
SepalLengthSepal Length (mm)10216.83333-632.2666718987.300007692.43333
SepalWidthSepal Width (mm)-632.266672830.69333-4911.88000-1812.42667
PetalLengthPetal Length (mm)18987.30000-4911.8800046432.5400019304.58000
PetalWidthPetal Width (mm)7692.43333-1812.4266719304.580008656.99333


In step 1, the tolerance is 1.0 for each variable under consideration because no variables have yet entered the model. The variable PetalLength is selected because its F statistic, 1180.161, is the largest among all variables.

Output 110.1.3: Iris Data: Stepwise Selection Step 1

Fisher (1936) Iris Data

The STEPDISC Procedure
Stepwise Selection: Step 1

Statistics for Entry, DF = 2, 147
VariableLabelR-SquareF ValuePr > FTolerance
SepalLengthSepal Length (mm)0.6187119.26<.00011.0000
SepalWidthSepal Width (mm)0.400849.16<.00011.0000
PetalLengthPetal Length (mm)0.94141180.16<.00011.0000
PetalWidthPetal Width (mm)0.9289960.01<.00011.0000

Variable PetalLength will be entered.

Variable(s) That
Have Been Entered
PetalLength

Multivariate Statistics
StatisticValueF ValueNum DFDen DFPr > F
Wilks' Lambda0.0586281180.162147<.0001
Pillai's Trace0.9413721180.162147<.0001
Average Squared Canonical Correlation0.470686    


In step 2, with the variable PetalLength already in the model, PetalLength is tested for removal before a new variable is selected for entry. Since PetalLength meets the criterion to stay, it is used as a covariate in the analysis of covariance for variable selection. The variable SepalWidth is selected because its F statistic, 43.035, is the largest among all variables not in the model and because its associated tolerance, 0.8164, meets the criterion to enter. The process is repeated in steps 3 and 4. The variable PetalWidth is entered in step 3, and the variable SepalLength is entered in step 4.

Output 110.1.4: Iris Data: Stepwise Selection Step 2

Fisher (1936) Iris Data

The STEPDISC Procedure
Stepwise Selection: Step 2

Statistics for Removal, DF = 2, 147
VariableLabelR-SquareF ValuePr > F
PetalLengthPetal Length (mm)0.94141180.16<.0001

No variables can be removed.

Statistics for Entry, DF = 2, 146
VariableLabelPartial
R-Square
F ValuePr > FTolerance
SepalLengthSepal Length (mm)0.319834.32<.00010.2400
SepalWidthSepal Width (mm)0.370943.04<.00010.8164
PetalWidthPetal Width (mm)0.253324.77<.00010.0729

Variable SepalWidth will be entered.

Variable(s) That Have Been
Entered
SepalWidthPetalLength

Multivariate Statistics
StatisticValueF ValueNum DFDen DFPr > F
Wilks' Lambda0.036884307.104292<.0001
Pillai's Trace1.11990893.534294<.0001
Average Squared Canonical Correlation0.559954    


Output 110.1.5: Iris Data: Stepwise Selection Step 3

Fisher (1936) Iris Data

The STEPDISC Procedure
Stepwise Selection: Step 3

Statistics for Removal, DF = 2, 146
VariableLabelPartial
R-Square
F ValuePr > F
SepalWidthSepal Width (mm)0.370943.04<.0001
PetalLengthPetal Length (mm)0.93841112.95<.0001

No variables can be removed.

Statistics for Entry, DF = 2, 145
VariableLabelPartial
R-Square
F ValuePr > FTolerance
SepalLengthSepal Length (mm)0.144712.27<.00010.1323
PetalWidthPetal Width (mm)0.322934.57<.00010.0662

Variable PetalWidth will be entered.

Variable(s) That Have Been Entered
SepalWidthPetalLengthPetalWidth

Multivariate Statistics
StatisticValueF ValueNum DFDen DFPr > F
Wilks' Lambda0.024976257.506290<.0001
Pillai's Trace1.18991471.496292<.0001
Average Squared Canonical Correlation0.594957    


Output 110.1.6: Iris Data: Stepwise Selection Step 4

Fisher (1936) Iris Data

The STEPDISC Procedure
Stepwise Selection: Step 4

Statistics for Removal, DF = 2, 145
VariableLabelPartial
R-Square
F ValuePr > F
SepalWidthSepal Width (mm)0.429554.58<.0001
PetalLengthPetal Length (mm)0.348238.72<.0001
PetalWidthPetal Width (mm)0.322934.57<.0001

No variables can be removed.

Statistics for Entry, DF = 2, 144
VariableLabelPartial
R-Square
F ValuePr > FTolerance
SepalLengthSepal Length (mm)0.06154.720.01030.0320

Variable SepalLength will be entered.

All variables have been entered.

Multivariate Statistics
StatisticValueF ValueNum DFDen DFPr > F
Wilks' Lambda0.023439199.158288<.0001
Pillai's Trace1.19189953.478290<.0001
Average Squared Canonical Correlation0.595949    


Since no more variables can be added to or removed from the model, the procedure stops at step 5 and displays a summary of the selection process.

Output 110.1.7: Iris Data: Stepwise Selection Step 5

Fisher (1936) Iris Data

The STEPDISC Procedure
Stepwise Selection: Step 5

Statistics for Removal, DF = 2, 144
VariableLabelPartial
R-Square
F ValuePr > F
SepalLengthSepal Length (mm)0.06154.720.0103
SepalWidthSepal Width (mm)0.233521.94<.0001
PetalLengthPetal Length (mm)0.330835.59<.0001
PetalWidthPetal Width (mm)0.257024.90<.0001

No variables can be removed.


Output 110.1.8: Iris Data: Stepwise Selection Summary

No further steps are possible.

Fisher (1936) Iris Data

The STEPDISC Procedure

Stepwise Selection Summary
StepNumber
In
EnteredRemovedLabelPartial
R-Square
F ValuePr > FWilks'
Lambda
Pr <
Lambda
Average
Squared
Canonical
Correlation
Pr >
ASCC
11PetalLength Petal Length (mm)0.94141180.16<.00010.05862828<.00010.47068586<.0001
22SepalWidth Sepal Width (mm)0.370943.04<.00010.03688411<.00010.55995394<.0001
33PetalWidth Petal Width (mm)0.322934.57<.00010.02497554<.00010.59495691<.0001
44SepalLength Sepal Length (mm)0.06154.720.01030.02343863<.00010.59594941<.0001


PROC STEPDISC automatically creates a list of the selected variables and stores it in a macro variable. You can submit the following statement to see the list of selected variables:

* print the macro variable list;
%put &_stdvar;

The macro variable _StdVar contains the following variable list:

   SepalLength SepalWidth PetalLength PetalWidth

You could use this macro variable if you want to analyze these variables in subsequent steps as follows:

proc discrim data=sashelp.iris;
   class Species;
   var &_stdvar;
run;

The results of this step are not shown.