Date: Thu, 25 Jun 2009 21:18:25 -0400 Francois van der Walt "SAS(r) Discussion" Francois van der Walt Re: bootstrap confidence intervals To: Daniel Nordlund

Daniel,

I could not resist. Here is some code that you might want to adapt.

/**************************************************************************************************** * Program name: * * Purpose: Demo of selecting sample size using bootstrap * * Description: Let us asume that we need to select a sample size that will detect an error in a * * population unsing bootstrap method. In this example the rate of errors is about 20%. * * In this case we use a sample of a 15 and want to estimate the probability of getting * * at least one error. We draw 500 samples of 15 each and look at the distribution. * * In this exmaple I used proc gchart to show the distribution from where I can read or * * see the probability to get ate least one error if I should decide to have a sample of* * 100. The sample size (100 in this case) can be increased or decreased utill the * * desired probability are reached. * * (In my experiments a sample size of ten will give one error 87% of the time * * A sample of 15 will give a 96% probability of detecting the error * * Written by: Francois van der Walt francoisw@gji.com.au Date: June 2009 * ****************************************************************************************************/ data pop; do i=1 to 1000; /* 1000 is the population size and can be changed */ if ranuni(0) <.2 then ind="Error"; /* .2 is the percentage errors in the population - change as needed*/ else ind="Correct"; output; end; data bootstrp; do k=1 to 500; /* 500 is the number of bootstraps */ errcount=0; corrcount=0; do j=1 to 15; /* 15 is the size of each bootstrap sample */ selobs=ranuni(0)*1000; /* 1000 is the population size and should match data pop do statement */ set pop point=selobs; if ind="Error" then ErrCount+1; else CorrCount+1; end; output; end; stop; run; proc gchart data=bootstrp; hbar ErrCount/discrete; run;

If you have questions send me an e-mail.

Kind regards Francois On Mon, 22 Jun 2009 15:02:39 -0700, Daniel Nordlund <djnordlund@VERIZON.NET> wrote:

>> -----Original Message----- >> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On >> Behalf Of Shiling Zhang >> Sent: Monday, June 22, 2009 2:54 PM >> To: SAS-L@LISTSERV.UGA.EDU >> Subject: Re: bootstrap confidence intervals >> >> Here is a basic example on how to use bootstrap resampling to do a >> regression. >> >> SAS surveyselect procedure provides a easy way to obtain a bootstrap >> resampling data set. The left over things are standard in regression. >> >> %let n=20; >> >> data t1; >> do i =1 to &n; >> x=rannor(567); >> y=1 + 1 *x +rannor(567); >> output; >> end; >> run; >> >> proc surveyselect seed=789 data=t1 >> METHOD=urs rate=1 >> rep=1000 outhits out=bootstrapped; >> run; >> >> proc print data=bootstrapped(obs=100); >> run; >> >> proc reg data=bootstrapped outest=est noprint; >> by replicate; >> model y = x ; >> run; >> quit; >> >> proc means data=est; >> var intercept x; >> run; >> >> proc reg data=t1 ; >> model y = x ; >> run; >> quit; >> >> >> >> On Jun 22, 9:11 am, adel_ta...@YAHOO.FR ("adel F.") wrote: >> > Hi,=0A=0AI=A0would like to =A0run a logistic regression >> models using bootst= >> > rap to get bootstrap confidence intervals for my odds >> ratios and bootstrap = >> > confidence intervals for AUC.=0A=0AIs there a SAS >> procedure, which can help= >> > me do that.=0A=0AThanks a lot,=0A=0AAdel=0A=0A=0A > >In addition to other advice/suggestions you have received, I highly >recommend the paper by David Cassell at the link below. > >http://www2.sas.com/proceedings/forum2007/183-2007.pdf > >Hope this is helpful, > >Dan > >Daniel Nordlund >Bothell, WA USA

Back to: Top of message | Previous page | Main SAS-L page