SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 64029: Area under the ROC curve measure (AUC) for multinomial models

DetailsResultsDownloadsAboutRate It

Area under the ROC curve measure (AUC) for multinomial models

Contents: Purpose / History / Requirements / Usage / Details / Limitations / Missing Values / See Also / References

 

PURPOSE:
The area under the ROC curve (AUC) is a widely used measure of model performance for binary-response models such as logistic models. Hand and Till (2001) proposed an extension to this measure for responses with more than two classes. The MultAUC macro implements this extended measure.
HISTORY:
The version of the MultAUC macro that you are using is displayed in the log when you specify version (or any string) as the first argument. For example:
    %MultAUC(version, <macro options>)

The MultAUC macro always attempts to check for a later version of itself. If it is unable to do this (such as if there is no active internet connection available), the macro will issue the following message:

    NOTE: Unable to check for newer version

The computations performed by the macro are not affected by the appearance of this message.

Version
Update Notes
1.3 Added prefix=. Final results data sets renamed as MultAUC and PairAUC.
1.1 Macro is now more robust to blanks and special characters in the response levels.
1.0 Initial coding
REQUIREMENTS:
The MultAUC macro requires Base SAS® and SAS/STAT® software.
USAGE:
Follow the instructions in the Downloads tab of this sample to save the MultAUC macro definition. Replace the text within quotation marks in the following statement with the location of the MultAUC macro definition file on your system. In your SAS program or in the SAS editor window, specify this statement to define the MultAUC macro and make it available for use:
   %inc "<location of your file containing the MultAUC macro>";

Following this statement, you can call the MultAUC macro. See the Results tab for examples.

The following macro parameters are optional:

data=data-set-name
Specifies the name of a data set containing a variable giving the observed response for each observation and a set of variables providing the predicted probabilities of each observation taking on each of the possible response levels. This data set is usually generated by an analytical procedure such as the LOGISTIC, GLIMMIX, DISCRIM or other procedure but could be from any source. If data= is omitted, then the last created data set is used.

The data set should contain only one observation for each original observation. Procedures that create an output data set containing multiple observations for each input observation must be edited to have only a single output observation per input observation. If the data set to be used is created by the OUTPUT statement in PROC LOGISTIC with the PREDPROBS=INDIVIDUAL option (not the PRED= option), then no alteration of the data set is needed.

response=variable
If specified, response= names a variable whose values identify the observed response level for each observation in the data= data set. If the data set is created by the OUTPUT statement in PROC LOGISTIC with the PREDPROBS=INDIVIDUAL option, then the response= option should be omitted. Otherwise, the values of variable must match (except possibly for a missing prefix) the names of the predicted probability variables in the data= data set. If the variable is numeric, then prefix= must also be specified to match the names of the predicted probabilities variables. If variable is a character variable, then it is recommended that any leading blanks be removed from its levels. See Limitations/Troubleshooting below for more information. The response levels (with any added prefix from prefix=) must be no more than 29 characters in length. The response= variable name should not be _from_.
prefix=string
Specifies a character string to add to the values in the response= variable to match the prefix string found at the beginning of the names of the predicted probability variables in the data= data set. If response= is specified and the response= variable is numeric, then prefix= is required. Do not include quotes in or around string. Use this option when the names of the predicted probability variables all begin with a character string which does not appear at the beginning of the levels of the response= variable values.
DETAILS:
A widely used measure of model performance for binary-response models is the area under the ROC curve (AUC) which is related to the Gini index. For a discussion of the ROC curve and the area beneath it in binary-response models, see the Receiver Operating Characteristic Curves section and the related examples in the PROC LOGISTIC chapter of the SAS/STAT User's Guide. See also Gönen (2007). For more on the ROC related capabilities in SAS, see the ROC item in the list of Frequently-Asked for Statistics.

Hand and Till (2001) extended the AUC measure to the multinomial case where the response has more than two levels. Their paper provides a good overview of both the binary and multinomial AUC statistics and their properties. Their multinomial measure reduces to the usual AUC when the response is binary (see Example 3). As with the binary AUC, the multinomial AUC ranges from 0 to 1, where 1 indicates a perfect fit and 0 represents a model that performs no better than chance. Note that in the multinomial case, a single ROC curve cannot be plotted.

The MultAUC macro is designed to work most easily with the data set created by the OUTPUT statement in PROC LOGISTIC in which the PREDPROBS=INDIVIDUAL (rather than the PRED= or P=) option is specified. When you fit a nominal (LINK=GLOGIT) or ordinal (LINK=LOGIT) model and specify the PREDPROBS=INDIVIDUAL option in the OUTPUT statement, the macro can be specified without options if called immediately after PROC LOGISTIC. If you use a different method that produces a data set with predicted probabilities of each response level for each observation, then specify response=, and prefix= if needed, to estimate the AUC.

The results from the macro are the overall AUC as well as the pairwise AUC values for each pair of response levels.

Output data sets

Results from the macro are available in two data sets. The overall AUC is saved in the MultAUC data set. The pairwise AUC values are saved in the PairAUC data set.

BY group processing

The MultAUC macro does not directly support BY group processing. That is, it cannot process results from a modeling procedure that was run using a BY statement. However, this capability can be provided by the RunBY macro which can run both the modeling procedure and the MultAUC macro for each of the BY groups in your data. See the RunBY macro documentation for details on its use. Also see the example titled "BY group processing" in the Results tab above.

LIMITATIONS / TROUBLESHOOTING:
No standard error, test, or confidence interval for AUC is currently available.

Some analytical procedures or methods remove leading blanks from the values of a character response variable when creating the names of the predicted probability variables. This can prevent the macro from correctly deriving the predicted probability variable names from the values of the response= variable. It is recommended that any leading blanks be removed from character response values either prior to the analysis that produces the data= data set or by modifying the values in the resulting data set. Leading (and trailing) blanks are easily removed using the CATS function in a DATA step statement such as:

response = cats(response);

MISSING VALUES:
Observations with missing response= variable are ignored. The variables containing the predicted probabilities for each observation must all be nonmissing. If the observation was ignored in the model fit, then all of its predicted probabilities are missing and the macro will similarly ignore the observation.
SEE ALSO:
"ROC" in the list of Frequently-Asked for Statistics.
REFERENCES:
Hand D.J. and Till R.J. (2001). "A Simple Generalisation of the Area Under the ROC Curve for Multiple Class Classification Problems." Machine Learning 45(2), p. 171-186.



These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.