How can I get the bootstrapped CI for range statistics?
5 views (last 30 days)
Show older comments
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
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])
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!