Why is bootci giving different interval than prctile?
Show older comments
I was trying to show confidence interval on a histogram with the following code.
n = 10e3;
data = randn(n,1);
alpha = 0.05;
nboot = 10e3;
mu = mean(data);
[ci,bootstat] = bootci(nboot,{@mean,data},"Alpha",alpha,"Type","percentile");
bootstat = bootstat-mu;
ci = ci-mu;
figure
histogram(bootstat,"Normalization","cdf")
hold on
yline(alpha, "Color","#D95319")
yline(1-alpha, "Color","#D95319")
xline(ci(1), "Color","#D95319")
xline(ci(2), "Color","#D95319")

The computed confidence interval does not aligne with the "cdf" histogram. But when I compute the interval using the following function, then it aligns as expected.
ci = prctile(bootstat, [alpha*100,(1-alpha)*100]);

Does anybody know, why is that the case?
Accepted Answer
More Answers (1)
the cyclist
on 16 Dec 2024
Because your prctile calculation should be
ci = prctile(bootstat, [(alpha/2)*100,(1-(alpha/2))*100]);
Categories
Find more on Resampling Techniques in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!