How to get the confidence interval for bootstrap?

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

 Respuesta aceptada

Adam Danz
Adam Danz el 26 de Nov. de 2021
Editada: Adam Danz el 28 de Nov. de 2021
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')
bci = 2×6
0.4915 0.9732 1.4090 1.9137 2.4013 2.9949 0.5350 1.0559 1.5363 2.0856 2.6109 3.2460
bmeans = 2000×6
0.5203 1.0467 1.4952 1.9917 2.4646 3.1421 0.5136 1.0534 1.4801 2.0494 2.5013 3.1802 0.5008 1.0113 1.4882 2.0149 2.5297 2.9563 0.5163 1.0236 1.5449 1.9367 2.5298 3.2134 0.5116 0.9381 1.4810 1.9140 2.4883 3.0335 0.5150 0.9864 1.5005 2.0132 2.5917 3.1490 0.5081 1.0345 1.4809 2.0112 2.4609 3.2744 0.5360 0.9740 1.4648 2.0291 2.5141 2.9913 0.4948 1.0058 1.4750 2.0584 2.5010 3.0882 0.5117 1.0126 1.4586 2.0869 2.5427 3.0350
bmu = mean(bmeans)
bmu = 1×6
0.5131 1.0148 1.4744 1.9976 2.5058 3.1196
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 comentarios

Temesgen
Temesgen el 15 de Feb. de 2024
Movida: Adam Danz el 15 de Feb. de 2024
Dear Adam Danz, How can I determine the confidence intervals of bootstrapped data if I have data sets such as 1418, 741, 1059, 1160, and 1129?
Thank you
Adam Danz
Adam Danz el 15 de Feb. de 2024
Do you mean you have 5 vectors that are those lengths or do you mean that you have a sincel multidimensional variable of size 1418x741x1160x1129? I assume you have 5 vectors.
In that case, you can perform the bootci on each vector individually or you can combine the vectors into a single matrix by making each vector a column vector and padding the shorter vectors with NaNs which will be ignored by bootci when using the omitnan flag.
Temesgen
Temesgen el 15 de Feb. de 2024
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
Adam Danz el 15 de Feb. de 2024
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.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 25 de Nov. de 2021

Comentada:

el 15 de Feb. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by