How do I specify stderr when using bootci to compute bootstrap studentized confidence interval?

5 views (last 30 days)
I want to compute the studentized bootstrap interval for the mean. The quantity to be computed for each bootstrap sample should be:
(mean(x)-mean(data))./std(x)
where x is a bootstrap sample. I can program this on my own, but I am not sure how to specify the same thing using the function bootci:
ci = bootci(B,{function1,data},'type','stud','stderr',function2);
What should I write for function1 and function2? I have tried several things but the coverages I get from these intervals turn out to be wrong (compared to my own program which I know is correct). I am specifying something incorrectly. Do I specify the divisor std(bootstrapsample) in function1, or in function2 (or in both)? The documentation is sparse.

Accepted Answer

Brendan Hamm
Brendan Hamm on 16 Mar 2015
It is not exactly clear what you are trying to do as you introduce x without explaining what it is. Assuming that you want to bootstrap samples and create a confidence interval round the mean then you do not need to specify function2. function1 would simply be a handle to the mean function as this is what you are looking for the interval on.
ci = bootci(B,{@mean,data},'type','stud')
This will give you a confidence interval around the mean for the variables in each column of data.
  5 Comments
Brendan Hamm
Brendan Hamm on 16 Mar 2015
I apologize, I made a mistake earlier. The function2 should just be the standard error function to use, and we passed it the function to compute the bootstrap statistic (noting that we should not have a dependence on sample size in this example as MATLAB utilizes the cancellation of this term in the CI calculation (as you did in yours). Therefore what you are looking for is:
B = 1e3; %nr resamples
n = 20; % sample size
mu = 3;
d = exprnd(mu,n,1);
ci = bootci(B,{@mean,data},'type','stud','stderr',@std);
This is the same standard error function MATLAB uses by default, but this will avoid the inner loop you mentioned.
In terms of speed the bootci function can be used on any statistic of your choosing and therefore cannot utilize vectorization as often as your example here.
Sorry for the confusion and I hope this helps.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!