How can I get the bootstrapped CI for range statistics?

5 views (last 30 days)
Hi,
I am trying to find the bootstrap confidence interval of the range value for cummulative normal random numbers.
How can I use bootci to find the correct CI of the range.
I wrote the test code below but It returns the wrong CI;
z=randn(100,1)
mn=mean(z)
sd=std(z)
range=fndrng(z)
f=@(z) fndrng(z)
[cirange, bootstatrange]=bootci(500,{f, z});
cirange
histogram(bootstatrange)
function rng=fndrng(x)
cums=0;
for i=1:length(x)
y(i)=cums+x(i)- mean(x);
cums=y(i);
end
rng=max(y)-min(y);
end
  3 Comments
Okan Fistikoglu
Okan Fistikoglu on 14 Oct 2020
Thank you for your interest, I generate a column vector x(i) with 100 normally distributed random numbers then calculate the accumulated vector y(i) like cusum (cumulative sum) as y(i)=y(i-1)+ x(i)-mean(x) and I find the range of y which is difference max(y) and min(y). Then finally I get the CI of range parameter of y by bootstrapping. The problem is the CI of the range (calculating by bootci and its default settings) seems problematic considering the histogram of the bootstraped range values.
Jeff Miller
Jeff Miller on 14 Oct 2020
"I generate a column...range parameter of y by bootstrapping". Yes, that is a very clear description of what your code does (though I still don't see why you want to do this). Well, no matter.
"seems problematic" how? Running your code, I see that the histogram of range values is skewed with a long tail at the high end. Maybe the CI seems problematic to you because it approaches the bottom of the histogram much more closely than it approaches the top? If that is what you are unhappy about, maybe one of the other methods of computing the bootstrap ci will look better. For example, you can use
[cirange, bootstatrange]=bootci(5000,{f, z}, 'type','per'); % or type 'cper'--see docs
to request a ci computed simply based on the percentiles of the bootstrap distribution, just the same as
bpcts = prctile(bootstatrange,[2.5, 97.5])

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!