Syntax


The following statements are available in PROC DISCRIM .

  • PROC DISCRIM < options > ;

    • CLASS variable ;

    • BY variables ;

    • FREQ variable ;

    • ID variable ;

    • PRIORS probabilities ;

    • TESTCLASS variable ;

    • TESTFREQ variable ;

    • TESTID variable ;

    • VAR variables ;

    • WEIGHT variable ;

Only the PROC DISCRIM and CLASS statements are required. The following sections describe the PROC DISCRIM statement and then describe the other statements in alphabetical order.

PROC DISCRIM Statement

  • PROC DISCRIM < options > ;

This statement invokes the DISCRIM procedure. You can specify the following options in the PROC DISCRIM statement.

Tasks

Options

Specify Input Data Set

DATA=

TESTDATA=

Specify Output Data Set

OUTSTAT=

OUT=

OUTCROSS=

OUTD=

TESTOUT=

TESTOUTD=

Discriminant Analysis

METHOD=

POOL=

SLPOOL=

Nonparametric Methods

K=

R=

KERNEL=

METRIC=

Classification Rule

THRESHOLD=

Determine Singularity

SINGULAR=

Canonical Discriminant Analysis

CANONICAL

CANPREFIX=

NCAN=

Resubstitution Classification

LIST

LISTERR

NOCLASSIFY

Cross Validation Classification

CROSSLIST

CROSSLISTERR

CROSSVALIDATE

Test Data Classification

TESTLIST

TESTLISTERR

Estimate Error Rate

POSTERR

Control Displayed Output

Correlations

BCORR

PCORR

TCORR

WCORR

Covariances

BCOV

PCOV

TCOV

WCOV

SSCP Matrix

BSSCP

PSSCP

TSSCP

WSSCP

Miscellaneous

ALL

ANOVA

DISTANCE

MANOVA

SIMPLE

STDMEAN

Suppress output

NOPRINT

SHORT

ALL

  • activates all options that control displayed output. When the derived classification criterion is used to classify observations, the ALL option also activates the POSTERR option.

ANOVA

  • displays univariate statistics for testing the hypothesis that the class means are equal in the population for each variable.

BCORR

  • displays between-class correlations.

BCOV

  • displays between-class covariances. The between-class covariance matrix equals the between-class SSCP matrix divided by n ( c ˆ’ 1) /c , where n is the number of observations and c is the number of classes. You should interpret the between-class covariances in comparison with the total-sample and within-class covariances, not as formal estimates of population parameters.

BSSCP

  • displays the between-class SSCP matrix.

CANONICAL

CAN

  • performs canonical discriminant analysis.

CANPREFIX= name

  • specifies a prefix for naming the canonical variables. By default, the names are Can1, Can2, ,Can n . If you specify CANPREFIX=ABC, the components are named ABC1, ABC2, ABC3, and so on. The number of characters in the prefix, plus the number of digits required to designate the canonical variables, should not exceed 32. The prefix is truncated if the combined length exceeds 32.

    The CANONICAL option is activated when you specify either the NCAN= or the CANPREFIX= option. A discriminant criterion is always derived in PROC DISCRIM. If you want canonical discriminant analysis without the use of discriminant criteria, you should use PROC CANDISC.

CROSSLIST

  • displays the cross validation classification results for each observation.

CROSSLISTERR

  • displays the cross validation classification results for misclassified observations only.

CROSSVALIDATE

  • specifies the cross validation classification of the input DATA= data set. When a parametric method is used, PROC DISCRIM classifies each observation in the DATA= data set using a discriminant function computed from the other observations in the DATA= data set, excluding the observation being classified. When a nonparametric method is used, the covariance matrices used to compute the distances are based on all observations in the data set and do not exclude the observation being classified. However, the observation being classified is excluded from the nonparametric density estimation (if you specify the R= option) or the k nearest neighbors (if you specify the K= option) of that observation. The CROSSVALIDATE option is set when you specify the CROSSLIST, CROSSLISTERR, or OUTCROSS= option.

DATA= SAS-data-set

  • specifies the data set to be analyzed . The data set can be an ordinary SAS data set or one of several specially structured data sets created by SAS/STAT procedures. These specially structured data sets include TYPE=CORR, TYPE=COV, TYPE=CSSCP, TYPE=SSCP, TYPE=LINEAR, TYPE=QUAD, and TYPE=MIXED. The input data set must be an ordinary SAS data set if you specify METHOD=NPAR. If you omit the DATA= option, the procedure uses the most recently created SAS data set.

DISTANCE

MAHALANOBIS

  • displays the squared Mahalanobis distances between the group means, F statistics, and the corresponding probabilities of greater Mahalanobis squared distances between the group means. The squared distances are based on the specification of the POOL= and METRIC= options.

K= k

  • specifies a k value for the k -nearest-neighbor rule. An observation x is classified into a group based on the information from the k nearest neighbors of x . Do not specify both the K= and R= options.

KERNEL=BIWEIGHT BIW

KERNEL=EPANECHNIKOV EPA

KERNEL=NORMAL NOR

KERNEL=TRIWEIGHT TRI

KERNEL=UNIFORM UNI

  • specifies a kernel density to estimate the group-specific densities . You can specify the KERNEL= option only when the R= option is specified. The default is KERNEL=UNIFORM.

LIST

  • displays the resubstitution classification results for each observation. You can specify this option only when the input data set is an ordinary SAS data set.

LISTERR

  • displays the resubstitution classification results for misclassified observations only. You can specify this option only when the input data set is an ordinary SAS data set.

MANOVA

  • displays multivariate statistics for testing the hypothesis that the class means are equal in the population.

METHOD=NORMAL NPAR

  • determines the method to use in deriving the classification criterion. When you specify METHOD=NORMAL, a parametric method based on a multivariate normal distribution within each class is used to derive a linear or quadratic discriminant function. The default is METHOD=NORMAL. When you specify METHOD=NPAR, a nonparametric method is used and you must also specify either the K= or R= option.

METRIC=DIAGONAL FULL IDENTITY

  • specifies the metric in which the computations of squared distances are performed. If you specify METRIC=FULL, PROC DISCRIM uses either the pooled covariance matrix (POOL=YES) or individual within-group covariance matrices (POOL=NO) to compute the squared distances. If you specify METRIC=DIAGONAL, PROC DISCRIM uses either the diagonal matrix of the pooled covariance matrix (POOL=YES) or diagonal matrices of individual within-group covariance matrices (POOL=NO) to compute the squared distances. If you specify METRIC=IDENTITY, PROC DISCRIM uses Euclidean distance. The default is METRIC=FULL. When you specify METHOD=NORMAL, the option METRIC=FULL is used.

NCAN= number

  • specifies the number of canonical variables to compute. The value of number must be less than or equal to the number of variables. If you specify the option NCAN=0, the procedure displays the canonical correlations but not the canonical coefficients, structures, or means. Let v be the number of variables in the VAR statement and c be the number of classes. If you omit the NCAN= option, only min( v, c ˆ’ 1) canonical variables are generated. If you request an output data set (OUT=, OUTCROSS=, TESTOUT=), v canonical variables are generated. In this case, the last v ˆ’ ( c ˆ’ 1) canonical variables have missing values.

    The CANONICAL option is activated when you specify either the NCAN= or the CANPREFIX= option. A discriminant criterion is always derived in PROC DISCRIM. If you want canonical discriminant analysis without the use of discriminant criterion, you should use PROC CANDISC.

NOCLASSIFY

  • suppresses the resubstitution classification of the input DATA= data set. You can specify this option only when the input data set is an ordinary SAS data set.

NOPRINT

  • suppresses the normal display of results. Note that this option temporarily disables the Output Delivery System (ODS); see Chapter 14, Using the Output Delivery System, for more information.

OUT= SAS-data-set

  • creates an output SAS data set containing all the data from the DATA= data set, plus the posterior probabilities and the class into which each observation is classified by resubstitution. When you specify the CANONICAL option, the data set also contains new variables with canonical variable scores. See the OUT= Data Set section on page 1170.

OUTCROSS= SAS-data-set

  • creates an output SAS data set containing all the data from the DATA= data set, plus the posterior probabilities and the class into which each observation is classified by cross validation. When you specify the CANONICAL option, the data set also contains new variables with canonical variable scores. See the OUT= Data Set section on page 1170.

OUTD= SAS-data-set

  • creates an output SAS data set containing all the data from the DATA= data set, plus the group-specific density estimates for each observation. See the OUT= Data Set section on page 1170.

OUTSTAT= SAS-data-set

  • creates an output SAS data set containing various statistics such as means, standard deviations, and correlations. When the input data set is an ordinary SAS data set or when TYPE=CORR, TYPE=COV, TYPE=CSSCP, or TYPE=SSCP, this option can be used to generate discriminant statistics. When you specify the CANONICAL option, canonical correlations, canonical structures, canonical coefficients, and means of canonical variables for each class are included in the data set. If you specify METHOD=NORMAL, the output data set also includes coefficients of the discriminant functions, and the output data set is TYPE=LINEAR (POOL=YES), TYPE=QUAD (POOL=NO), or TYPE=MIXED (POOL=TEST). If you specify METHOD=NPAR, this output data set is TYPE=CORR. This data set also holds calibration information that can be used to classify new observations. See the Saving and Using Calibration Information section on page 1167 and the OUT= Data Set section on page 1170.

PCORR

  • displays pooled within-class correlations.

PCOV

  • displays pooled within-class covariances.

POOL=NO TEST YES

  • determines whether the pooled or within-group covariance matrix is the basis of the measure of the squared distance. If you specify POOL=YES, PROC DISCRIM uses the pooled covariance matrix in calculating the (generalized) squared distances. Linear discriminant functions are computed. If you specify POOL=NO, the procedure uses the individual within-group covariance matrices in calculating the distances. Quadratic discriminant functions are computed. The default is POOL=YES.

    When you specify METHOD=NORMAL, the option POOL=TEST requests Bartlett s modification of the likelihood ratio test (Morrison 1976; Anderson 1984) of the homogeneity of the within-group covariance matrices. The test is unbiased (Perlman 1980). However, it is not robust to nonnormality. If the test statistic is significant at the level specified by the SLPOOL= option, the within-group covariance matrices are used. Otherwise, the pooled covariance matrix is used. The discriminant function coefficients are displayed only when the pooled covariance matrix is used.

POSTERR

  • displays the posterior probability error-rate estimates of the classification criterion based on the classification results.

PSSCP

  • displays the pooled within-class corrected SSCP matrix.

R= r

  • specifies a radius r value for kernel density estimation. With uniform, Epanechnikov, biweight, or triweight kernels , an observation x is classified into a group based on the information from observations y in the training set within the radius r of x , that is, the group t observations y with squared distance . When a normal kernel is used, the classification of an observation x is based on the information of the estimated group-specific densities from all observations in the training set. The matrix r 2 V t is used as the group t covariance matrix in the normal-kernel density, where V t is the matrix used in calculating the squared distances. Do not specify both the K= and R= options. For more information on selecting r , see the Nonparametric Methods section on page 1158.

SHORT

  • suppresses the display of certain items in the default output. If you specify METHOD= NORMAL, PROC DISCRIM suppresses the display of determinants , generalized squared distances between-class means, and discriminant function coefficients. When you specify the CANONICAL option, PROC DISCRIM suppresses the display of canonical structures, canonical coefficients, and class means on canonical variables; only tables of canonical correlations are displayed.

SIMPLE

  • displays simple descriptive statistics for the total sample and within each class.

SINGULAR= p

  • specifies the criterion for determining the singularity of a matrix, where 0 < p < 1. The default is SINGULAR=1E ˆ’ 8.

    Let S be the total-sample correlation matrix. If the R 2 for predicting a quantitative variable in the VAR statement from the variables preceding it exceeds 1 ˆ’ p , then S is considered singular. If S is singular, the probability levels for the multivariate test statistics and canonical correlations are adjusted for the number of variables with R 2 exceeding 1 ˆ’ p .

    Let S t be the group t covariance matrix and S p be the pooled covariance matrix. In group t , if the R 2 for predicting a quantitative variable in the VAR statement from the variables preceding it exceeds 1 ˆ’ p , then S t is considered singular. Similarly, if the partial R 2 for predicting a quantitative variable in the VAR statement from the variables preceding it, after controlling for the effect of the CLASS variable, exceeds 1 ˆ’ p , then S p is considered singular.

    If PROC DISCRIM needs to compute either the inverse or the determinant of a matrix that is considered singular, then it uses a quasi-inverse or a quasi-determinant. For details, see the Quasi-Inverse section on page 1164.

SLPOOL= p

  • specifies the significance level for the test of homogeneity. You can specify the SLPOOL= option only when POOL=TEST is also specified. If you specify POOL= TEST but omit the SLPOOL= option, PROC DISCRIM uses 0.10 as the significance level for the test.

STDMEAN

  • displays total-sample and pooled within-class standardized class means.

TCORR

  • displays total-sample correlations.

TCOV

  • displays total-sample covariances.

TESTDATA= SAS-data-set

  • names an ordinary SAS data set with observations that are to be classified. The quantitative variable names in this data set must match those in the DATA= data set. When you specify the TESTDATA= option, you can also specify the TESTCLASS, TESTFREQ, and TESTID statements. When you specify the TESTDATA= option, you can use the TESTOUT= and TESTOUTD= options to generate classification results and group-specific density estimates for observations in the test data set. Note that if the CLASS variable is not present in the TESTDATA= data set, the output will not include misclassification statistics.

TESTLIST

  • lists classification results for all observations in the TESTDATA= data set.

TESTLISTERR

  • lists only misclassified observations in the TESTDATA= data set but only if a TESTCLASS statement is also used.

TESTOUT= SAS-data-set

  • creates an output SAS data set containing all the data from the TESTDATA= data set, plus the posterior probabilities and the class into which each observation is classified. When you specify the CANONICAL option, the data set also contains new variables with canonical variable scores. See the OUT= Data Set section on page 1170.

TESTOUTD= SAS-data-set

  • creates an output SAS data set containing all the data from the TESTDATA= data set, plus the group-specific density estimates for each observation. See the OUT= Data Set section on page 1170.

THRESHOLD= p

  • specifies the minimum acceptable posterior probability for classification, where 0 p 1. If the largest posterior probability of group membership is less than the THRESHOLD value, the observation is classified into group OTHER. The default is THRESHOLD=0.

TSSCP

  • displays the total-sample corrected SSCP matrix.

WCORR

  • displays within-class correlations for each class level.

WCOV

  • displays within-class covariances for each class level.

WSSCP

  • displays the within-class corrected SSCP matrix for each class level.

BY Statement

  • BY variables ;

You can specify a BY statement with PROC DISCRIM to obtain separate analyses on observations in groups defined by the BY variables. When a BY statement appears, the procedure expects the input data set to be sorted in order of the BY variables.

If your input data set is not sorted in ascending order, use one of the following alternatives:

  • Sort the data using the SORT procedure with a similar BY statement.

  • Specify the BY statement option NOTSORTED or DESCENDING in the BY statement for the DISCRIM procedure. The NOTSORTED option does not mean that the data are unsorted but rather that the data are arranged in groups (according to values of the BY variables) and that these groups are not necessarily in alphabetical or increasing numeric order.

  • Create an index on the BY variables using the DATASETS procedure (in base SAS software).

For more information on the BY statement, refer to SAS Language Reference: Concepts . For more information on the DATASETS procedure, see the discussion in the SAS Procedures Guide .

If you specify the TESTDATA= option and the TESTDATA= data set does not contain any of the BY variables, then the entire TESTDATA= data set is classified according to the discriminant functions computed in each BY group in the DATA= data set.

If the TESTDATA= data set contains some but not all of the BY variables, or if some BY variables do not have the same type or length in the TESTDATA= data set as in the DATA= data set, then PROC DISCRIM displays an error message and stops.

If all BY variables appear in the TESTDATA= data set with the same type and length as in the DATA= data set, then each BY group in the TESTDATA= data set is classified by the discriminant function from the corresponding BY group in the DATA= data set. The BY groups in the TESTDATA= data set must be in the same order as in the DATA= data set. If you specify the NOTSORTED option in the BY statement, there must be exactly the same BY groups in the same order in both data sets. If you omit the NOTSORTED option, some BY groups may appear in one data set but not in the other. If some BY groups appear in the TESTDATA= data set but not in the DATA= data set, and you request an output test data set using the TESTOUT= or TESTOUTD= option, these BY groups are not included in the output data set.

CLASS Statement

  • CLASS variable ;

The values of the classification variable define the groups for analysis. Class levels are determined by the formatted values of the CLASS variable. The specified variable can be numeric or character. A CLASS statement is required.

FREQ Statement

  • FREQ variable ;

If a variable in the data set represents the frequency of occurrence for the other values in the observation, include the variable s name in a FREQ statement. The procedure then treats the data set as if each observation appears n times, where n is the value of the FREQ variable for the observation. The total number of observations is considered to be equal to the sum of the FREQ variable when the procedure determines degrees of freedom for significance probabilities.

If the value of the FREQ variable is missing or is less than one, the observation is not used in the analysis. If the value is not an integer, it is truncated to an integer.

ID Statement

  • ID variable ;

The ID statement is effective only when you specify the LIST or LISTERR option in the PROC DISCRIM statement. When the DISCRIM procedure displays the classification results, the ID variable (rather than the observation number) is displayed for each observation.

PRIORS Statement

  • PRIORS EQUAL;

  • PRIORS PROPORTIONAL PROP;

  • PRIORS probabilities ;

The PRIORS statement specifies the prior probabilities of group membership. To set the prior probabilities equal, use

  priors equal;  

To set the prior probabilities proportional to the sample sizes, use

  priors proportional;  

For other than equal or proportional priors, specify the prior probability for each level of the classification variable. Each class level can be written as either a SAS name or a quoted string, and it must be followed by an equal sign and a numeric constant between zero and one. A SAS name begins with a letter or an underscore and can contain digits as well. Lowercase character values and data values with leading blanks must be enclosed in quotes. For example, to define prior probabilities for each level of Grade , where Grade s values are A, B, C, and D, the PRIORS statement can be

  priors A=0.1 B=0.3 C=0.5 D=0.1;  

If Grade s values are a , b , c , and d , each class level must be written as a quoted string:

  priors 'a'=0.1 'b'=0.3 'c'=0.5 'd'=0.1;  

If Grade is numeric, with formatted values of 1 , 2 , and 3 , the PRIORS statement can be

  priors '1'=0.3 '2'=0.6 '3'=0.1;  

The specified class levels must exactly match the formatted values of the CLASS variable. For example, if a CLASS variable C has the format 4.2 and a value 5, the PRIORS statement must specify 5.00 , not 5.0 or 5 . If the prior probabilities do not sum to one, these probabilities are scaled proportionally to have the sum equal to one. The default is PRIORS EQUAL.

TESTCLASS Statement

  • TESTCLASS variable ;

The TESTCLASS statement names the variable in the TESTDATA= data set that is used to determine whether an observation in the TESTDATA= data set is misclassified. The TESTCLASS variable should have the same type (character or numeric) and length as the variable given in the CLASS statement. PROC DISCRIM considers an observation misclassified when the formatted value of the TESTCLASS variable does not match the group into which the TESTDATA= observation is classified. When the TESTCLASS statement is missing and the TESTDATA= data set contains the variable given in the CLASS statement, the CLASS variable is used as the TESTCLASS variable. Note that if the CLASS variable is not present in the TESTDATA= data set, the output will not include misclassification statistics.

TESTFREQ Statement

  • TESTFREQ variable ;

If a variable in the TESTDATA= data set represents the frequency of occurrence for the other values in the observation, include the variable s name in a TESTFREQ statement. The procedure then treats the data set as if each observation appears n times, where n is the value of the TESTFREQ variable for the observation.

If the value of the TESTFREQ variable is missing or is less than one, the observation is not used in the analysis. If the value is not an integer, it is truncated to an integer.

TESTID Statement

  • TESTID variable ;

The TESTID statement is effective only when you specify the TESTLIST or TESTLISTERR option in the PROC DISCRIM statement. When the DISCRIM procedure displays the classification results for the TESTDATA= data set, the TESTID variable (rather than the observation number) is displayed for each observation. The variable given in the TESTID statement must be in the TESTDATA= data set.

VAR Statement

  • VAR variables ;

The VAR statement specifies the quantitative variables to be included in the analysis. The default is all numeric variables not listed in other statements.

WEIGHT Statement

  • WEIGHT variable ;

To use relative weights for each observation in the input data set, place the weights in a variable in the data set and specify the name in a WEIGHT statement. This is often done when the variance associated with each observation is different and the values of the weight variable are proportional to the reciprocals of the variances. If the value of the WEIGHT variable is missing or is less than zero, then a value of zero for the weight is used.

The WEIGHT and FREQ statements have a similar effect except that the WEIGHT statement does not alter the degrees of freedom.




SAS.STAT 9.1 Users Guide (Vol. 2)
SAS/STAT 9.1 Users Guide Volume 2 only
ISBN: B003ZVJDOK
EAN: N/A
Year: 2004
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net