# Bootstrap clarification of question

Ok I've been trying to interpret what they actually want me to do here, I've been sititng with this exact question for 1,5 days now:

What confuses me is the sentence "Draw 1000 samples of this size, for each samle calculate a bootstrap CI".

Then I'm supposed to calculate how many of these confidence interval covers the theoretical mean, which in this case is $$\theta = 4$$.

Do they mean that I should, for $$n=10$$, calculate 1000 CI's? We're drawing from a gamma distribution, here is what I have done:

# CI for n = 10
n = 10
K = vector("numeric", 1000L)
S = vector("numeric", 1000L)  #Create vectors to contain information

for (i in 1:1000){
x = sample(rgamma(n,k,gamma), n)  # For every iteration, compute the mean of the
K[i] = mean(x)                      # 10 samples and place it in index i in K.
}

S = sort(K)
Upper = S[975]
Lower = S[25]


So doing a CI now, it would just give me ONE CI for all these 1000 means, but I want 1000 CI's, don't I?

I'm not sure if I've interpreted this correctly :S

From my understanding of the bootstrap, you're right, obtaining 1000 bootstrap samples for $$\hat \theta$$ will give you a single CI. Perhaps you're expected to repeat this many times over.
1. R's sample function has the replace variable set to FALSE by default, you need to sample with replacement while doing a bootstrap.
2. Note that rgamma uses an $$\alpha, \beta$$ parameterization unless you explicitly state scale = $$\theta$$. I can't see where the k variable is defined, so I'm not sure if you're using the right parameterization.