DATA Step, Macro, Functions and more

Bootstrap CI - PLZ help

Reply
Occasional Contributor
Posts: 19

Bootstrap CI - PLZ help

The attached sas program to find optimal operating point (MGYI) along with the sas format. MGYI can be found by proc means which is a single measure used to summarize the performance of c1 and c2. The attached observed sample is considered to be the population that needs resample 2000 samples with replacement and every time calculates MGYI, c1 and c2. Then perform bootstrap confidence interval on MGYI, c1 and c2.


LIBNAME FRMT 'C:\project';run;
OPTIONS FMTSEARCH=(FRMT);run;
data rocBP;
input c2 c1 y id ;
cards;
148 33.6 1 1
85 26.6 0 2
183 23.3 1 3
89 28.1 0 4
137 43.1 1 5
116 25.6 0 6
78 31 1 7
115 35.3 0 8
197 30.5 1 9
110 37.6 0 11
168 38 1 12
139 27.1 0 13
189 30.1 1 14
166 25.8 1 15
100 30 1 16
118 45.8 1 17
107 29.6 1 18
103 43.3 0 19
115 34.6 1 20
126 39.3 0 21
99 35.4 0 22
196 39.8 1 23
119 29 1 24
143 36.6 1 25
125 31.1 1 26
147 39.4 1 27
97 23.2 0 28
145 22.2 0 29
117 34.1 0 30
;
data rocBP;
set rocBP;
Sensitivity = 1-probbnrm((c1-35.4)/6.63,(c2-142.5)/29.64, 0);
FP = 1-probbnrm((c1-30.8)/6.57,(c2-110.8)/24.8, 0);
FPR=FP;
condition = ceil(FPR*200)/200 ;
Costp01 = (probnorm((c1-35.4)/6.63))* 0.1 + (probnorm((c1-30.8)/6.57))*(1-0.1) ;
run;quit;
proc sort data=rocBP; by FP;run;quit;
proc means data=rocBP max noprint;
var Sensitivity; by FP;
output out=mrocBP (drop=_type_ _freq_)
max=MTPR
maxid(Sensitivity(condition))=condition ;
format FP lessthan.;
run;quit;
/**************************************** MCMROC******************************************************************************/
******************************************BP, p=0.1, q=1 *******************************************;
proc sort data=rocBP; by condition ;run;
proc sort data=mrocBP; by condition ;run;
data mrocBPq;
merge rocBP mrocBP;
by condition;
run;
data mrocBPq1;
set mrocBPq;
TPRmaxq = 1 * MTPR ;
if Sensitivity >= TPRmaxq then q=1;
else q=0;
if q=0 then delete;
run;
proc sort data=mrocBPq1 ; by FP;run;
proc means data=mrocBPq1 min noprint;
var Costp01; by FP;
output out=mincBPq1p01 (drop=_type_ _freq_)
min=cost
minid(Costp01(c1))=c1
minid(Costp01(c2))=c2
minid(Costp01(FPR))=FPR
minid(Costp01(condition))=condition
minid(Costp01(MTPR))=MTPR
minid(Costp01(Sensitivity))=Sensitivity;
format FP lessthan.;
run;quit;
/**** Calculate optimal operating point(MGYI) *** *************************************************************************/
data Optimalq1p01a10;
set mincBPq1p01;
GYI = Sensitivity + ((1-0.1)/(10*0.1)) * (1- FPR);
run;
data costq1p01a10;
set Optimalq1p01a10;
run;
proc means data=costq1p01a10 max noprint;
var GYI;
output out=MGYIcq1p01a10 (drop=_type_ _freq_)
maxid(GYI(c1))=c1
maxid(GYI(c2))=c2
max=MGYI ;
run;
proc print data = MGYIcq1p01a10; run;
Trusted Advisor
Posts: 2,116

Re: Bootstrap CI - PLZ help

Between this paper
http://www2.sas.com/proceedings/sugi29/193-29.pdf
and the SAS macro for bootstrapping,
http://support.sas.com/kb/24/982.html
you should have no problem getting your estimates.
Occasional Contributor
Posts: 19

Re: Bootstrap CI - PLZ help

Dear Doc@Duke,
Thank so much for help. I am successfully generated 1000 bootstrap samples from the original data. The new dataset include (c1 c2 y id bootsamp). For each bootstrap sample, I need to calculate MGYI and associated c1 and c2 by using the following code. It seems macro need to be used here. Need your help on setting macro (I am not good with macro). I would appreciated.


data rocBP;
set rocBP;
Sensitivity = 1-probbnrm((c1-35.4)/6.63,(c2-142.5)/29.64, 0);
FP = 1-probbnrm((c1-30.8)/6.57,(c2-110.8)/24.8, 0);
FPR=FP;
condition = ceil(FPR*200)/200 ;
Costp01 = (probnorm((c1-35.4)/6.63))* 0.1 + (probnorm((c1-30.8)/6.57))*(1-0.1) ;
run;quit;
proc sort data=rocBP; by FP;run;quit;
proc means data=rocBP max noprint;
var Sensitivity; by FP;
output out=mrocBP (drop=_type_ _freq_)
max=MTPR
maxid(Sensitivity(condition))=condition ;
format FP lessthan.;
run;quit;
/**************************************** MCMROC******************************************************************************/
******************************************BP, p=0.1, q=1 *******************************************;
proc sort data=rocBP; by condition ;run;
proc sort data=mrocBP; by condition ;run;
data mrocBPq;
merge rocBP mrocBP;
by condition;
run;
data mrocBPq1;
set mrocBPq;
TPRmaxq = 1 * MTPR ;
if Sensitivity >= TPRmaxq then q=1;
else q=0;
if q=0 then delete;
run;
proc sort data=mrocBPq1 ; by FP;run;
proc means data=mrocBPq1 min noprint;
var Costp01; by FP;
output out=mincBPq1p01 (drop=_type_ _freq_)
min=cost
minid(Costp01(c1))=c1
minid(Costp01(c2))=c2
minid(Costp01(FPR))=FPR
minid(Costp01(condition))=condition
minid(Costp01(MTPR))=MTPR
minid(Costp01(Sensitivity))=Sensitivity;
format FP lessthan.;
run;quit;
/**** Calculate optimal operating point(MGYI) *** *************************************************************************/
data Optimalq1p01a10;
set mincBPq1p01;
GYI = Sensitivity + ((1-0.1)/(10*0.1)) * (1- FPR);
run;
data costq1p01a10;
set Optimalq1p01a10;
run;
proc means data=costq1p01a10 max noprint;
var GYI;
output out=MGYIcq1p01a10 (drop=_type_ _freq_)
maxid(GYI(c1))=c1
maxid(GYI(c2))=c2
max=MGYI ;
run;
proc print data = MGYIcq1p01a10; run;
Ask a Question
Discussion stats
  • 2 replies
  • 125 views
  • 0 likes
  • 2 in conversation