2

I have calculated the empirical distribution of the sample mean using the bootstrap method, but now I would also need to calculate the confidence interval for the population mean using the empirical distribution I found.

Is there a way to do it automatically in Matlab given my state? If not, how would you find the 95% confidence interval for population mean?

nbro
  • 15,395
  • 32
  • 113
  • 196

1 Answers1

2

The bootstrapped confidence intervals for the mean as you have calculated it are the quantiles of the distribution. So, it can be as simple as

quantile(myBootstrappedMeans, [0.05, 0.95])

That will give a 90% confidence interval for the vector myBootstrappedMeans. For reference, http://math.usask.ca/~longhai/doc/talks/slide-bootstrap.pdf

0.05 and 0.95 are for the 90% confidence interval (the middle 90% of the data). For a different confidence interval, you would just need to choose the middle quantiles of that data. So, for 95% you would use 0.025 and 0.975. To generalize, you would use (1-level)/2 and (0.5 + level/2) where level is the confidence interval (or confidence level) that you want.

Bill Denney
  • 766
  • 1
  • 6
  • 21
  • Ok, thanks. But what is the meaning of the name of the function ("quantile") that you are using? I understood it returns the extremes of the interval, what does the word "quantile" has to do with this? From the Matlab documentation, I am not sure I am understanding. I am really new to these things. – nbro Dec 16 '15 at 03:33
  • @rbro the `quantile` function returns the [quantiles](https://en.wikipedia.org/wiki/Quantile) of a data set. For example, the 0.5 quantile is the median, and the 0.25, 0.5 and 0.75 quantiles together are known as the quartiles. You may also have heard of the term *percentile* - the 100 * *q*th percentile is the same as the *q*th quantile. – Chris Taylor Dec 16 '15 at 08:02
  • It's not only about capturing the middle 95% of the distribution, it's also (and maybe more importantly) about finding the _shortest_ interval that does it. – ayorgo Jun 29 '19 at 16:31
  • @ayorgo, while confidence intervals (CI) are not unique, they are not typically computed as the shortest interval. CI are typically computed by quantiles of the data in one of three ways: centered (where a 90% CI would go from the 0.05 to 0.95 quantiles), and right or right (where the 90% CI could go from the 0.1 or to the 0.9 quantiles). The shortest interval would select a higher fraction of the data on the more compressed side of an asymmetric distribution. I don't know of a field where that is done. (Though I'm happy to learn of one!) – Bill Denney Jul 07 '19 at 12:55