# Bootstrap confidence interval programming

Suppose I have the following data set called form the file results. I want to write a bootstrap program using both SAS and R to determine the confidence interval for the mean proportion. If a student get > 50 marks then it is a pass or else it is a fail. The number of replication must be 1000.

exam 23 56 48 87 94 56 98 62 63 45 85 75 49 79 68 58 36 82 81 73 36 69 76 88 96 50 40 49 66 48 70 61 58 63 78 85 78 30

• You can use the R package boot for this purpose. Consider the commands boot and boot.ci. – user10525 Oct 4 '12 at 15:01
• For SAS, take a look at David Cassell's paper Don't be Loopy – Peter Flom - Reinstate Monica Oct 4 '12 at 15:37
• @PeterFlom That is the same advice you gave me. Are you at all familiar with J. D. Opdyke's efficient SAS macros for bootstrapping. He had a paper on it in a Wiley online journal that I recently refereed. – Michael R. Chernick Oct 4 '12 at 17:05
• I don't know those – Peter Flom - Reinstate Monica Oct 4 '12 at 17:22
• @PeterFlom, MichaelChernick: Peter, The paper to which Michael is referring is now posted under Early Views on the Computational Statistics: WIREs journal webpage at onlinelibrary.wiley.com/doi/10.1002/wics.1266/abstract A preprint can be downloaded at datamineit.com/DMI_publications.htm All feedback is appreciated. Best, J.D. Opdyke – user27299 Jun 25 '13 at 19:18

Here's some R code:

B = 1000
n = length(data)#data is the name of your vector of data
bootstrap.proportion = rep(NA, n) #vector to store the bootstrap values
for(b in 1:B){
bootstrap.sample = sample(data, n, replace = TRUE)
bootstrap.proportion[b] = mean(bootstrap.sample)
}
sort(bootstrap.proportion)


The lower limit of the bootstrap confidence interval is the $\alpha / 2$ and the upper limit is the $1-\alpha / 2$ element of this sorted set.

• You are explaining the percentile method bootstrap to the OP. Maybe we should mention that there are the higher order accurate bootstrap CI such as iterated bootstrap, bootstrap t and BCa. I imagine the R packages allow the use of these other bootstraps. – Michael R. Chernick Oct 4 '12 at 17:07
• To add to @MichaelChernick 's comment, R has a package called "boot" for bootstrapping. – power Feb 2 '13 at 4:35