BART Procedure
Example 4.2 Probit Model for Binary Data
(View the complete code for this example.)
This example uses the junk email available in the Sashelp.JunkMail data set. The 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 table, which is specified in the following DATA step, contains 4,601 observations, with two 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 parts. The 57 explanatory variables are continuous variables that represent the frequencies of some common words and characters and the lengths of uninterrupted sequences of capital letters in emails.
data mylib.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, and the rest of the data are used to evaluate the fit. You use the DIST= option in the MODEL statement to indicate that the response is binary.
proc bart data=mylib.JunkMail seed=210124;
model Class = 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
/ dist=binary;
partition rolevar=Test(train='0' test='1');
run;
The "Number of Observations" and "Response Profile" tables in Output 4.2.1 are divided into training and testing columns.
Output 4.2.1: Partitioned Counts
| Number of Observations Read | 4601 |
|---|---|
| Number of Observations Used | 4601 |
| Number of Observations Used for Training | 3065 |
| Number of Observations Used for Testing | 1536 |
| Response Profile | ||
|---|---|---|
| Class | Training | Testing |
| 1 | 1218 | 595 |
| 0 | 1847 | 941 |
| Probability modeled is Class = 0. |
The fit statistics for the selected model are displayed in the "Fit Statistics" table in Output 4.2.2. The misclassification rate and average square error are similar for the training and testing data, indicating that the fitted model generalizes well.
Output 4.2.2: Partitioned Fit Statistics
| Fit Statistics | ||
|---|---|---|
| Training | Testing | |
| Average Square Error | 0.03995 | 0.04744 |
| Misclassification Rate | 0.04698 | 0.06055 |
To enable you to further assess the performance of the model, the "Classification Matrix" table in Output 4.2.3 displays information about the observed and predicted values for both the training and test data.
Output 4.2.3: Partitioned Classification Matrix
| Classification Matrix | ||||||
|---|---|---|---|---|---|---|
| Observed | Training Prediction | Testing Prediction | ||||
| 0 | 1 | Total | 0 | 1 | Total | |
| 0 | 1790 | 57 | 1847 | 901 | 40 | 941 |
| 1 | 87 | 1131 | 1218 | 53 | 542 | 595 |
| Total | 1877 | 1188 | 3065 | 954 | 582 | 1536 |