The HPDECIDE Procedure

Example 6.1 Using a Revenue Matrix and Cost Variables to Make Decisions

This fictitious example demonstrates how to use PROC HPDECIDE to adjust posterior probabilities and how to use a revenue matrix and cost variables to make decisions. In the following DATA steps, the categorical target variable tar has two levels in the data set data1: a and b.

    data data1(drop=i);
        do i=1 to 5;
        tar="b";
        if i<3 then tar="a";
        p_a=abs(ranuni(81923));
        p_b=abs(1-p_a);
        c1=ranpoi(38192,5);
        c2=ranpoi(28131,7);
        output;
        end;
    run;

    data decdata1(type=revenue);
        input dv1-dv2 op np tar $;
        DATALINES;
        5 3 .5 .2 a
        6 3 .5 .8 b
    ;

The estimated posterior probabilities that correspond to the categories of the target variable are denoted by p_a and p_b. The two cost variables, c1 and c2, represent the target-specific consequences for the decision variables dv1 and dv2, respectively. The variable op contains the "old" prior probabilities that were used the first time the model was fictitiously fit. The variable np contains the "new" prior probabilities that are used to make decisions.

The following statements take the data set data1 and the data set decdata1, and output the data set out1 and the data set outstat1. The target variable is tar. Because the input data set resides on the client and no PERFORMANCE statement is specified, the client performs all computations.

 proc hpdecide data=data1 out=out1 outstat=outstat1;
     decision decdata=decdata1 decvars=dv1-dv2
     oldpriorvar=op priorvar=np cost=c1 c2;
     posteriors p_a p_b;
     target tar;
     performance details nthreads=2;
 run;

 proc print data=out1;
 var p_a p_b I_tar F_tar dv1 dv2 D_DECDATA1 EP_DECDATA1 CP_DECDATA1;
 run;

 proc print data=outstat1;
 run;

Output 6.1.1 shows the out1 data set, which displays the decision for each observation. The adjusted posterior probabilities are also shown in the out1 data set.

Output 6.1.1: out1 Data Set

Obsp_ap_bI_tarF_tardv1dv2D_DECDATA1EP_DECDATA1CP_DECDATA1
10.356020.64398BA0.64398-6dv10.643980
20.385710.61429BA0.61429-1dv10.614290
30.189220.81078BB-1.18922-2dv1-1.18922-1
40.110350.88965BB4.889650dv14.889655
50.291580.70842BB-3.29158-2dv2-2.00000-2


Output 6.1.2 shows the outstat1 data set, which shows that the total profit is 2.6666666667 and the average profit is 0.5333333333, based on the decisions from the out1 data set.

Output 6.1.2: outstat1 Data Set

Obs_PROF__APROF_
12.666670.53333


Output 6.1.3 shows the performance information.

Output 6.1.3: Performance Information

The HPDECIDE Procedure

Performance Information
Execution ModeSingle-Machine
Number of Threads2


Last updated: May 25, 2022