How to get the confidence interval for bootstrap?
조회 수: 7 (최근 30일)
이전 댓글 표시
HI Everyone,
My data set consists of 185 columns and 53 rows. Each coloumn consists of integeres and NaN enteries. I need to delete only NaN enteries from each column and then run a bootstrap for each coloumn (I am not sure either I did this correctly or not please have a look on the script). However, I only get a single bootstrap value for each column. May someone sugget me how I can get upper and lower bounds for bootstrap.
clc
clear all
clc
u = readmatrix('R_0.01.csv');
s=u';
s=sort(s);
nBoot=2000;
for i=1:185
bb=s(:,i);
X = bb(~isnan(bb));
[bci(:,i),bmeans(:,i)] = bootci(nBoot,{@mean,X},'alpha',.1,'type','per');
bmu(i,1) = mean(bmeans(:,i));
end
댓글 수: 0
채택된 답변
Adam Danz
2021년 11월 26일
편집: Adam Danz
2021년 11월 28일
Why are you sorting s in s=sort(s)?
There's no need to manually eliminate the NaN values and there's no need to use a loop.
Here's a demo. bci is 2*n for n columns of s showing the [lower; upper] CIs.
u = rand(6,500) .* (1:6)';
s=u';
% s=sort(s);
nBoot=2000;
[bci,bmeans] = bootci(nBoot,{@(v)mean(v,'omitnan'),s},'alpha',.1,'type','per')
bmu = mean(bmeans)
Plot CIs to see if they make sense. The red lines within each boxplot show the median values. The light blue error bars are the CIs around the mean values.
clf()
boxplot(s)
hold on
errorbar(1:numel(bmu), bmu, bmu-bci(1,:), bmu-bci(2,:), 'LineStyle', 'none')
댓글 수: 4
Temesgen
2024년 2월 15일
Thank you for your reply. I have these 5 vectors (my original data). I want to create 5 bootstrape samples and calculate their means and the max. as well as the min. values.
Adam Danz
2024년 2월 15일
Have you tried using the solution in my answer above? Replace s in line that calls bootci with a vector. Then repeat with the other vectors.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!