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 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 | ||
|---|---|---|
| Description | Training | Testing |
| -2 Log Likelihood | 1242.59491 | 823.68742 |
| AIC (smaller is better) | 1292.59491 | 873.68742 |
| AICC (smaller is better) | 1293.02268 | 874.54835 |
| SBC (smaller is better) | 1443.28998 | 1007.11085 |
| Average Square Error | 0.05659 | 0.06353 |
| -2 Log L (Intercept-only) | 4118.98701 | 2050.73514 |
| R-Square | 0.60877 | 0.55016 |
| Max-rescaled R-Square | 0.82359 | 0.74661 |
| McFadden's R-Square | 0.69833 | 0.59835 |
| Misclassification Rate | 0.07471 | 0.07813 |
| Difference of Means | 0.75122 | 0.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.