Bootstrapping Logistic Regression

Bootstrapping Logistic Regression

Generates m new training data sets. Each new training data set picks a sample of observations with replacement (bootstrap sample) from original data set. By sampling with replacement, some observations may be repeated in each new training data set. The m models are fitted using the above m bootstrap samples and combined by averaging the output (for regression).
%MACRO boot (data=,target=, ivars=, n=,outfile=);

%DO i=1 %to &n;

data bootstrap;
choice = INT(RANUNI(23456+&i)*n)+1;
set &data POINT = choice NOBS = n;
ch = choice;
j+1;
IF j > n then stop;
run;

ods output ParameterEstimates = mest;
proc logistic data=bootstrap descending;
model &target= &ivars/ selection=stepwise stb;
run;
ods output close;

data mest;
set mest;
helper = abs (StandardizedEst);
run;

proc rank data = mest descending tied = low out=mest (drop= helper);
var helper;
ranks Importance;
run;

proc append base=&outfile data=mest;
%end;

proc means data= &outfile MIN MEAN MEDIAN MAX;
where variable ne 'Intercept';
class variable ;
var Importance;
run;

%MEND boot;

%boot(data=mydata,target= bad, ivars=var1 var2 var3, n=10,outfile=res);
About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 8 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Telecom and Human Resource.

Related Posts:
5 Responses to "Bootstrapping Logistic Regression"
  1. Pls can you provide this in Base SAS codes and not macros?

    Thanks.

    ReplyDelete
  2. Pls can you provide this in Base SAS codes and not macros?Thanks.

    ReplyDelete
  3. hello,
    i really appreciate ur great work.

    but i would like to know how would u specify categorical variable in proc logistic part of this marcro. there is no class statement O.o

    ReplyDelete
    Replies
    1. You can add class statement and define your variable there and make sure adding that categorical variable in the right hand side of model = statement.

      Delete
  4. Hi, please can you tell me the importance of ranking instead of original ones?

    ReplyDelete

Next → ← Prev
Love this Post? Spread the Word!
Share