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

The BART Procedure

Number of Observations Read4601
Number of Observations Used4601
Number of Observations Used for Training3065
Number of Observations Used for Testing1536

Response Profile
ClassTrainingTesting
11218595
01847941

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
 TrainingTesting
Average Square Error0.039950.04744
Misclassification Rate0.046980.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
ObservedTraining PredictionTesting Prediction
01Total01Total
0179057184790140941
1871131121853542595
Total1877118830659545821536


Last updated: May 14, 2026