PARTIALDEPEND Procedure
Example 26.2 Compute Partial Dependence for a Nominal Target Variable
This example shows how to use the PARTIALDEPEND procedure to estimate the partial dependence (PD) function for a nominal target variable. It also shows how to generate an ICE table.
The following DATA step creates the input data table mylib.hmeq. In this example, an observation ID variable, _ID_, is added to help index the ICE curves for individuals.
data mylib.hmeq;
set sampsio.hmeq;
_ID_ =_n_;
run;
The following statements run the FOREST procedure to build a forest model to estimate the probability that mortgage loan applicants will default on repayment of their loan. The procedure also outputs an analytic store named forestStore_hmeq.
proc forest data = mylib.hmeq seed = 1234;
input DebtInc Value Loan Mortdue / level = interval;
input Job Reason / level = nominal;
target Bad / level = nominal;
saveState rstore = mylib.forestStore_hmeq;
run;
Note that the target variable Bad, which has two numeric levels (0 and 1), is defined as a nominal variable. The following statements run PROC PARTIALDEPEND and produce the PD plot with ODS Graphics enabled:
ods graphics on; /* Enables ODS Graphics */
proc PartialDepend data = mylib.hmeq seed = 1234;
input Job Reason / level = nominal;
input DebtInc Value Loan Mortdue / level = interval;
predictedTarget P_Bad1;
analysisVariable Job;
astoreModel rstore = mylib.forestStore_hmeq;
output out = mylib.ICE_out copyvars = (_ID_);
run;
The DATA= option specifies the data table to use for PD analysis. The SEED= option specifies the seed to use for pseudorandom number generation. The two INPUT statements specify that the Job, Reason, DebtInc, Value, Loan, and Mortdue variables be used as inputs. The PREDICTEDTARGET statement specifies that the P_Bad1 variable be used as the predicted target. The ANALYSISVARIABLE statement specifies that the Job variable be used as the analysis variable. The ASTOREMODEL statement with the RSTORE= option specifies that the analytic store saved in the data table mylib.forestStore_hmeq be used as the model for analysis. The OUTPUT statement with the OUT= and COPYVARS= options specifies that the ICE values for each sampled individual be saved in the data table mylib.ICE_out, with the variable _ID_ copied to the output data table.
Output 26.2.1 displays the average predicted probability of loan default (BAD=1) by each Job level. Output 26.2.2 displays the average predicted probability of loan default by Job as a plot. It also displays the number of observations for each level of the analysis variable in the sampled data (labeled as "Count") at the bottom of the graph.
Output 26.2.1: Partial Dependence Table
| Partial Dependence | ||||
|---|---|---|---|---|
| Bin (Job) | JOB | Mean Prediction (P_Bad1) | Standard Error (P_Bad1) | Count |
| 1 | Other | 0.210981092 | 0.0083166049 | 405 |
| 2 | ProfExe | 0.1916962576 | 0.0079161127 | 222 |
| 3 | Office | 0.1684452274 | 0.0068102209 | 158 |
| 4 | Mgr | 0.211865001 | 0.0083646163 | 139 |
| 5 | Self | 0.260902705 | 0.0092112979 | 36 |
| 6 | Sales | 0.3445961044 | 0.0078446872 | 16 |
Output 26.2.2: Partial Dependence Plot
