I am trying to calculate the 95% confidence intervals around a mean value using a bootstrap procedure, from the mosaic pacakge, to deal with some assumption issues in my data. The code below seems to work just fine; however, it yields non-symmetrical confidence intervals around the mean. This seems wrong to me, but I can't figure out where the mistake may lie.

Question 1: is there an error in my formatting of the code that would yield this result?
Question 2: Can you explain why these confidence intervals would not be symmetrical around the mean? (I know this isn't a stats forum, but I think it might be a coding issue so I posted it here)


    RB12xbar <- mean(~rb12N, data = rb12)



    rb12trials<- do(1000)*mean(~rb12N,data=resample(rb12))
    histogram(~result, data=rb12trials,xlab="Mean data",col="gray")

    confint(rb12trials, level=0.95,method="quantile")

below is a selection of the results from the above code, as well as the data used in it

   year  rb12N
1   pre 2.5390
2   pre 1.3241
3   pre 3.2659
4   pre 3.4864
5   pre 3.5254
6   pre 3.1138
7   pre 3.8610
8   pre 3.9623
9   pre 3.7300
10  pre 2.6925
11  pre 2.6095
12  pre 3.0573
13  pre 3.2646
14  pre 2.7921
15  pre 3.3147
16  pre 2.6095
17  pre 3.2073
18  pre 3.3153
> RB12xbar
[1] 3.092817
> confint(rb12trials, level=0.95,method="quantile")
    name    lower    upper level   method
1 result 2.808446 3.341967  0.95 quantile
  • 10
    $\begingroup$ bootstrapped confidence intervals won't necessarily be symmetric because they aren't constrained by a symmetric parametric distribution (ie. normal) $\endgroup$ – Rorschach Jul 2 '15 at 19:37
  • 1
    $\begingroup$ For this reason it's a stats q not a programming one, and I've voted to migrate $\endgroup$ – David Robinson Jul 2 '15 at 19:44
  • $\begingroup$ Thank you Legalizelt, So it's not a problem with my code? It's a true result? $\endgroup$ – Jesse001 Jul 2 '15 at 19:48
  • 1
    $\begingroup$ It's as "true" as statistics can achieve. $\endgroup$ – DWin Jul 2 '15 at 20:03
  • $\begingroup$ The intuition for this question is: look at a $\chi^2$ distribution. Would you expect a confidence interval to be symmetric around the mean of that? $\endgroup$ – MichaelChirico Jul 3 '15 at 3:02

The Central Limit Theorem states that the distribution of the sample mean approaches a normal distribution as the sample size increases. Here you are resampling from a very small sample, $n=18$, so the CLT does not apply. The number of bootstrap resamples will allow for better or worse approximation of the distribution of the sample mean, but that distribution need not be approximately normal unless there is a sufficiently large sample of the underlying population from which to resample.

Your histogram of the bootstrap mean with this data should not appear normal. Here's the one I got, note the skew,

histogram of bootstrap mean

from coding this up in base .

boot<-function(x,FUN=mean,n=1000) replicate(n,FUN(sample(x,replace=TRUE)))
hist(b,main="Histogram of bootstrap mean")
#      5%      95% 
#2.840431 3.317798 

In this particular case, the small sample size contains an "outlier", 1.3241, significantly outside the range of most of the data points which contributes to the effect.

| cite | improve this answer | |

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.