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:

enter image description here

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.

See this Q&A, the explanation here regarding the bootstrap CIs is really good.

On a side note, a note of caution:

  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.
  • $\begingroup$ Hello, indeed, i realised this and set replace = TRUE. For the parameters, k = 2, gamma = 1/2. I'll take a look at tha tlink you've probided, thank you! $\endgroup$ – Fabled Oct 3 '18 at 10:12

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.