Download presentation
Presentation is loading. Please wait.
1
Examining model stability, an example
proc logistic data=s5238.chd5238 outest=betas; model chd10yr(event="1")=age male sbp chol diab currsmok/ selection=forward; run; proc print data=betas;run;
2
Select 100 bootstrap samples
%bootsamp(indat=s5238.chd5238,outdat=outboot,reps=100,seed= );
3
Re-do analysis for each bootstrap sample
proc logistic data=outboot outest=betas noprint; by replicate; model chd10yr(event="1")=age male sbp chol diab currsmok/ selection=forward; run; proc print data=betas;run;
4
A simple summary. proc means data=betas;
var age male sbp chol diab currsmok; run;
5
Another summary – create a string that is six characters long
Another summary – create a string that is six characters long. Each character is 0 or The first character is 1 if the first variable is in the model, 0 if it is not. The same for the other two characters.
6
%macro zeroone(indat=,outdat=models,newvar=model,vars=);
%let numvars=%sysfunc(countw(&vars)); data &outdat; length &newvar $ &numvars..; set &indat; array t{&numvars} &vars; do i=1 to &numvars; substr(&newvar,i,1)=put((t{i} ne .),1.); end; run; %mend;
7
%zeroone(indat=betas,outdat=models,newvar=model,vars= age male sbp chol diab currsmok);
proc freq data=models; table model; run;
8
A much more complex model
A much more complex model. Lots of interaction terms, no hierarchical model restrictions. proc logistic data=s5238.chd5238 outest=betas descending ; model chd10yr=age | male | chol | sbp | bmi | diab | currsmok / selection=forward slentry=.1 hierarchy=none;/*single is default*/ run;
9
Do the complex model on the bootstrap samples.
proc logistic data=outboot outest=betas descending noprint; by replicate; model chd10yr=age | male | chol | sbp | bmi | diab | currsmok / selection=forward slentry=.1 hierarchy=none;/*single is default*/ run;
10
The problem -- Lots of variable names.
%zeroone(indat=betas,outdat=models,newvar=model,vars= age male sbp chol diab currsmok); proc contents data=betas; run;
11
Use SQL to put variables names into a macro variable
proc sql; select name into :varnames separated by " " from dictionary.columns where libname="WORK" and memname="BETAS" and type="num" and lowcase(name) ne "replicate" and lowcase(name) ne "intercept" and name ne "_LNLIKE_" ; quit; %let numvars=%sysfunc(countw("&varnames")); %put &numvars; %put &varnames;
12
Now use the zeroone macro
%zeroone(indat=betas,outdat=models1,newvar=model,vars=&varnames); proc sql; create table nummodels as select distinct model from models1 ; select count(*) "Number of distinct models" from nummodels quit;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.