The DISCRIM Procedure

Getting Started: DISCRIM Procedure

(View the complete code for this example.)

The data in this example are measurements of 159 fish caught in Finland’s Lake Laengelmaevesi; this data set is available from Puranen (1917). For each of the seven species (bream, roach, whitefish, parkki, perch, pike, and smelt) the weight, length, height, and width of each fish are tallied. Three different length measurements are recorded: from the nose of the fish to the beginning of its tail, from the nose to the notch of its tail, and from the nose to the end of its tail. The height and width are recorded as percentages of the third length variable. The fish data set is available from the Sashelp library. The goal now is to find a discriminant function based on these six variables that best classifies the fish into species.

First, assume that the data are normally distributed within each group with equal covariances across groups. The following statements use PROC DISCRIM to analyze the Sashelp.Fish data and create Figure 36.1 through Figure 36.5:

title 'Fish Measurement Data';

proc discrim data=sashelp.fish;
   class Species;
run;

The DISCRIM procedure begins by displaying summary information about the variables in the analysis (see Figure 36.1). 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, its weight, the proportion of the total sample, and the prior probability are also displayed. Equal priors are assigned by default.

Figure 36.1: Summary Information

Fish Measurement Data

The DISCRIM Procedure

Total Sample Size158DF Total157
Variables6DF Within Classes151
Classes7DF Between Classes6

Number of Observations Read159
Number of Observations Used158

Class Level Information
SpeciesVariable
Name
FrequencyWeightProportionPrior
Probability
BreamBream3434.00000.2151900.142857
ParkkiParkki1111.00000.0696200.142857
PerchPerch5656.00000.3544300.142857
PikePike1717.00000.1075950.142857
RoachRoach2020.00000.1265820.142857
SmeltSmelt1414.00000.0886080.142857
WhitefishWhitefish66.00000.0379750.142857


The natural log of the determinant of the pooled covariance matrix is displayed in Figure 36.2.

Figure 36.2: Pooled Covariance Matrix Information

Pooled Covariance Matrix
Information
Covariance
Matrix Rank
Natural Log of the
Determinant of the
Covariance Matrix
64.17613


The squared distances between the classes are shown in Figure 36.3.

Figure 36.3: Squared Distances

Fish Measurement Data

The DISCRIM Procedure

Generalized Squared Distance to Species
From SpeciesBream Parkki Perch Pike Roach Smelt Whitefish
Bream083.32523243.66688310.52333133.06721252.75503132.05820
Parkki83.32523057.09760174.2091827.0009660.5207626.54855
Perch243.6668857.097600101.0679129.2163229.2680620.43791
Pike310.52333174.20918101.06791092.40876127.8217799.90673
Roach133.0672127.0009629.2163292.40876033.842806.31997
Smelt252.7550360.5207629.26806127.8217733.84280046.37326
Whitefish132.0582026.5485520.4379199.906736.3199746.373260


The coefficients of the linear discriminant function are displayed (in Figure 36.4) with the default options METHOD=NORMAL and POOL=YES.

Figure 36.4: Linear Discriminant Function

Linear Discriminant Function for Species
VariableBream Parkki Perch Pike Roach Smelt Whitefish
Constant-185.91682-64.92517-48.68009-148.06402-62.65963-19.70401-67.44603
Weight-0.10912-0.09031-0.09418-0.13805-0.09901-0.05778-0.09948
Length1-23.02273-13.64180-19.45368-20.92442-14.63635-4.09257-22.57117
Length2-26.70692-5.3819517.330616.19887-7.47195-3.639963.83450
Length350.5578020.895315.2599322.9498925.0070210.6017121.12638
Height13.916388.44567-1.42833-8.99687-0.26083-1.845690.64957
Width-23.71895-13.385921.32749-9.13410-3.74542-3.43630-2.52442


A summary of how the discriminant function classifies the data used to develop the function is displayed last. In Figure 36.5, you see that only three of the observations are misclassified. The error-count estimates give the proportion of misclassified observations in each group. Since you are classifying the same data that are used to derive the discriminant function, these error-count estimates are biased.

Figure 36.5: Resubstitution Misclassification Summary

Fish Measurement Data

The DISCRIM Procedure
Classification Summary for Calibration Data: SASHELP.FISH
Resubstitution Summary using Linear Discriminant Function

Number of Observations and Percent Classified into Species
From SpeciesBream Parkki Perch Pike Roach Smelt WhitefishTotal
Bream
34
100.00
0
0.00
0
0.00
0
0.00
0
0.00
0
0.00
0
0.00
34
100.00
Parkki
0
0.00
11
100.00
0
0.00
0
0.00
0
0.00
0
0.00
0
0.00
11
100.00
Perch
0
0.00
0
0.00
53
94.64
0
0.00
0
0.00
3
5.36
0
0.00
56
100.00
Pike
0
0.00
0
0.00
0
0.00
17
100.00
0
0.00
0
0.00
0
0.00
17
100.00
Roach
0
0.00
0
0.00
0
0.00
0
0.00
20
100.00
0
0.00
0
0.00
20
100.00
Smelt
0
0.00
0
0.00
0
0.00
0
0.00
0
0.00
14
100.00
0
0.00
14
100.00
Whitefish
0
0.00
0
0.00
0
0.00
0
0.00
0
0.00
0
0.00
6
100.00
6
100.00
Total
34
21.52
11
6.96
53
33.54
17
10.76
20
12.66
17
10.76
6
3.80
158
100.00
Priors
0.14286
 
0.14286
 
0.14286
 
0.14286
 
0.14286
 
0.14286
 
0.14286
 
 
 

Error Count Estimates for Species
 Bream Parkki Perch Pike Roach Smelt WhitefishTotal
Rate0.00000.00000.05360.00000.00000.00000.00000.0077
Priors0.14290.14290.14290.14290.14290.14290.1429 


One way to reduce the bias of the error-count estimates is to split your data into two sets. One set is used to derive the discriminant function, and the other set is used to run validation tests. Example 36.4 shows how to analyze a test data set. Another method of reducing bias is to classify each observation by using a discriminant function computed from all of the other observations; this method is invoked with the CROSSVALIDATE option.