The LOGSELECT Procedure

Example 11.3 Partitioning Data

The Sashelp.JunkMail data set comes from a study that classifies whether an email is junk email (coded as 1) or not (coded as 0). The data were collected by Hewlett-Packard Labs and donated by George Forman. The data set, which is specified in the following DATA step, contains 4,601 observations, with 2 binary variables and 57 continuous explanatory variables. The response variable, Class, is a binary indicator of whether an email is considered spam or not. The partitioning variable, Test, is a binary indicator that is used to divide the data into training and testing sets. The 57 explanatory variables are continuous variables that represent frequencies of some common words and characters and lengths of uninterrupted sequences of capital letters in emails.

data mycas.JunkMail;
   set Sashelp.JunkMail;
run;

In the following program, the PARTITION statement divides the data into two parts. The training data have a Test value of 0 and contain about two-thirds of the data; the rest of the data are used to evaluate the fit. A forward selection method selects the best model based on the training observations.

proc logselect data=mycas.JunkMail;
   model Class(event='1')=Make Address All _3d Our Over Remove Internet Order
         Mail Receive Will People Report Addresses Free Business Email You
         Credit Your Font _000 Money HP HPL George _650 Lab Labs Telnet _857
         Data _415 _85 Technology _1999 Parts PM Direct CS Meeting Original
         Project RE Edu Table Conference Semicolon Paren Bracket Exclamation
         Dollar Pound CapAvg CapLong CapTotal;
   partition rolevar=Test(train='0' test='1');
   selection method=forward;
run;

Selected results from the analysis are shown in Output 11.3.1 and Output 11.3.2.

The "Number of Observations" and "Response Profile" tables in Output 11.3.1 are divided into training and testing columns.

Output 11.3.1: Partitioned Counts

The LOGSELECT Procedure

Number of Observations
DescriptionTotalTrainingTesting
Number of Observations Read460130651536
Number of Observations Used460130651536

Response Profile
Ordered
Value
ClassTotal
Frequency
TrainingTesting
1027881847941
2118131218595

Probability modeled is Class = 1.



The likelihood-based fit statistics for the selected model are displayed in the "Fit Statistics" table in Output 11.3.2, which has columns for the training and testing subsets.

Output 11.3.2: Partitioned Fit Statistics

Fit Statistics
DescriptionTrainingTesting
-2 Log Likelihood1242.59491823.68742
AIC (smaller is better)1292.59491873.68742
AICC (smaller is better)1293.02268874.54835
SBC (smaller is better)1443.289981007.11085
Average Square Error0.056590.06353
-2 Log L (Intercept-only)4118.987012050.73514
R-Square0.608770.55016
Max-rescaled R-Square0.823590.74661
McFadden's R-Square0.698330.59835
Misclassification Rate0.074710.07813
Difference of Means0.751220.73431


These statistics are computed for both the training and testing data. The statistics include the likelihood-based R-square statistics as well as several prediction-based statistics that are described in the section Model Fit and Assessment Statistics. The ASE, the misclassification rate, and the difference of means should be very similar between the two groups when the training data are representative of the testing data; for this model, the values of these statistics seem similar between the two disjoint subsets.

If you want to display all the fit statistics without partitioning your data table, you can specify the PARTFIT option as follows:

proc logselect data=mycas.JunkMail(where Test=0) partfit;
   model Class(event='1')= Our Over Remove Internet Order Will
         Free Business You Your Font _000 Money HP George Parts
         Meeting RE Edu Semicolon Exclamation Dollar CapAvg
         CapLong;
run;

The resulting "Fit Statistics" table is identical to the Training column in Output 11.3.2.

Last updated: December 21, 2018