I have 2x2 design with n = 3 (averages) for each group (see here). I am not sure that my data follows any particular distribution, but I would like to use confidence intervals as error bars in a dot plot. Thus I can't really use sd, se or bootstrapping from a distribution. The approach I am after is described in this article. My initial feeling is that I should use boot package. I have 3 replicates, which consist of different number of measurements. I would like to use averages of these replicates to calculate the confidence intervals. Something like:

x1 <- rnorm(50, 14,3)
x2 <- rnorm(35, 7,1)
x3 <- rnorm(40, 15,9)

d <- c(mean(x1), mean(x2), mean(x3))
b <- boot(d, function(u,i) mean(u[i]), R = 999, sim = "ordinary")
boot.ci(b, type = c("all"))

The help file for boot()function says "For the nonparametric bootstrap, possible resampling methods are the ordinary bootstrap, the balanced bootstrap, antithetic resampling, and permutation". Without background in statistics, I am having hard time understanding what do these different options do and what would be the most suitable for this case. boot.ci() function gives 5 different answers, which all seem to differ considerably. I am pretty confused. Could anyone clarify following related questions:

  1. Is this a right approach?
  2. Which combination should I use in this case?
  3. Why so many options?
  • $\begingroup$ Ok, I wasn't sure which forum to use, since it includes R stuff too. Maybe someone could kindly move it there? $\endgroup$
    – Mikko
    Commented Apr 27, 2012 at 13:47
  • $\begingroup$ Your question is not directed towards programming, you already found the package and the code. Your question relates to the statistics, which is the subject of CrossValidated. There are also a lot of R savy people there. $\endgroup$ Commented Apr 27, 2012 at 13:48
  • 2
    $\begingroup$ I agree with the stackexchange suggestion. I hope someone there will tell you that with 3 data points, there's really extremely little point using fancy methods to compute confidence intervals. Without making assumptions about the distribution, it will be almost impossible to nail down confidence intervals. What do you think the 95% confidence intervals are of {1,2,13} ... ??? $\endgroup$
    – Ben Bolker
    Commented Apr 27, 2012 at 14:23
  • $\begingroup$ @BenBolker: sideways-eight. $\endgroup$ Commented Apr 27, 2012 at 14:30
  • 1
    $\begingroup$ Just show the points! Add a horizontal bar at the mean if you really care about that. $\endgroup$
    – Aniko
    Commented Apr 27, 2012 at 14:40

1 Answer 1


I think you are proceeding incorrectly. You should be constructing :


And then examining the statistics of interest before applying them to the samples.

  • $\begingroup$ But wouldn't this make measurements within x1,x2, and x3 replicates in a sense? To me they occur more like pseudo-replicates and means of x1, x2, and x3 would be the replicates. Maybe I am wrong? $\endgroup$
    – Mikko
    Commented Apr 27, 2012 at 15:06
  • 1
    $\begingroup$ If you have a more complex design you will need to incorporate that into the object you create. Perhaps you need something like: d<-data.frame( X <- c(rnorm(50, 14,3), rnorm(35, 7,1), rnorm(40, 15,9)), idx=rep(c("X","Y","Z"), each=c(50,35,40))). The principle is to make data in the same form as would be occuring in the experiment, .... before the analysis. $\endgroup$
    – DWin
    Commented Apr 27, 2012 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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