2
$\begingroup$

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

$\endgroup$
  • $\begingroup$ You can use the R package boot for this purpose. Consider the commands boot and boot.ci. $\endgroup$ – user10525 Oct 4 '12 at 15:01
  • 1
    $\begingroup$ For SAS, take a look at David Cassell's paper Don't be Loopy $\endgroup$ – Peter Flom Oct 4 '12 at 15:37
  • $\begingroup$ @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. $\endgroup$ – Michael Chernick Oct 4 '12 at 17:05
  • $\begingroup$ I don't know those $\endgroup$ – Peter Flom Oct 4 '12 at 17:22
  • 2
    $\begingroup$ @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 $\endgroup$ – user27299 Jun 25 '13 at 19:18
2
$\begingroup$

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.

$\endgroup$
  • 2
    $\begingroup$ 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. $\endgroup$ – Michael Chernick Oct 4 '12 at 17:07
  • $\begingroup$ To add to @MichaelChernick 's comment, R has a package called "boot" for bootstrapping. $\endgroup$ – power Feb 2 '13 at 4:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.