# Number of bootstrap replicates versus number of simulations

I have some confusion over bootstrap simulation in R. Here is the question: I am asked to use the following parameters to produce simulation:

• 500 bootstrap replicates
• 1000 simulations
• Sample size of $$n=\{10,20,100,1000\}$$
• Draw your samples from a beta distribution with $$\alpha=2$$ and $$\beta=5$$

For each sample size/simulation draw a simple random sample of size $$n$$ from the population. In each simulation, calculate a t confidence interval for the sample mean (using $$\alpha =0.1$$). I am confused here about the difference between the number of bootstrap replicates and the number of simulations. Could someone explain or provide an example of how this works? Thanks!

For example, if I was trying for $$n=10$$:

samp <- rbeta(10,2,5)
boot_samp_dist <- replicate(500, {mean(samp[sample.int(length(samp), replace = TRUE)])})


Here I assume I'm resampling with replacement 500 times, but how would I incorporate the 1000 simulations?

• The sequence of events is important here. Oct 10, 2018 at 7:55
• @user2974951 Thanks, but could you explain a bit more detail on how to apply this in the code above? Oct 10, 2018 at 8:17
• Do you have the exact text for this task? Oct 10, 2018 at 8:53
• @user2974951 I was asked not to use the ''boot" command in R, so I'm trying to reconstruct the bootstrap process using other command. I'm trying to calculate a t confidence interval for the sample mean. Oct 10, 2018 at 9:03

I don't know the exact task is, but what I think they are asking of you is

for (n in 1:1000) { #1000 simulations
for (s in c(10,20,100,1000)) { #sample sizes
temp=rbeta(s,2,5) #random sample given sample size
temp2=replicate(500,sample(temp,replace=T)) #500 bootstrap samples
quantile(temp2,c(0.05,0.95)) #bootstrap 90 % CI
}
}


Note the code is not vectorized or optimized, you can do that later. The last command is what you are interested in and you would save this somewhere.

• Thanks a lot! In the end of the task asks for the nominal coverage probability, maybe this is why they give the # of simulations? Oct 10, 2018 at 9:35
• At the end of the simulations you would check how many times your estimated bootstrap sample CI was correct. Oct 10, 2018 at 9:39