How to change bootci sample size (bootstrap confidence interval)?

4 次查看(过去 30 天)
I'd like to adapt MATLAB's bootci function to perform resampling with a specified size.
Currently, I've implemented a basic resampling method with a fixed sample size (sizeBoot).
Here's the (slow) code snippet:
% Create random data from a normal distribution
% with mean 28.25 and sd 8.5.
data = (randn(1,100000)*8.5 + 28.25)';
nBoot = 2000; % Number of bootstraps
sizeBoot = 500; % Resampling size (bootci default is size(data))
bootMeans = nan(1, nBoot);
for i = 1:Boot_number
bootMeans(i) = mean(data(randi(numel(data), sizeBoot)));
end
% Bootci (fast)
[bci,bmeans] = bootci(nBoot,{@mean,data},'alpha',.1,'type','per'); %90 confidence interval
I believe the solution involves modifying MATLAB's bootci and bootstrp functions.
However, this task exceeds my current capabilities. Could you provide any guidance or ideas on how to achieve this modification effectively (while keeping the confidence interval types and parallel options)?
  3 个评论
Ricardo
Ricardo 2024-2-19
Hello, thank you for your response.
I'm currently working on replicating some studies that utilize this method in a two-step bootstrap approach.
In the first step, I'm calculating financial return series and in the second step, I'm performing confidence interval (CI) calculations following Politis and Romano’s subsampling bootstrap.
So based on my intuition, I think that this approach is intended to improve efficiency?
Given this, I've presumed that using bootci would be the more efficient choice, especially if I can calculate the percentile ('perc') and bias-corrected and accelerated ('bca') CI methods alongside its parallel computing capabilities while reducing the sample size.
https://www.tandfonline.com/doi/abs/10.1080/1351847X.2015.1029590
Adam Danz
Adam Danz 2024-2-19
Thanks for the refences @Ricardo.
The percentile CIs can be computed from the bootMeans created in your for-loop.
data = (randn(100000,1)*8.5 + 28.25);
nBoot = 2000; % Number of bootstraps
sizeBoot = 500; % Resampling size (bootci default is size(data))
alpha = 0.1;
n = numel(data);
bootMeans = nan(nBoot,1);
for i = 1:nBoot
bootMeans(i) = mean(data(randi(n, sizeBoot, 1)));
end
interval = [alpha/2, 1 - alpha/2] * 100;
CI = prctile(bootMeans,interval)
CI = 1×2
27.6042 28.8503
A comparsion of this method vs bootci is explained here and shows that these methods are equivalent.
Here's the vectorized version.
data = (randn(100000,1)*8.5 + 28.25);
nBoot = 2000; % Number of bootstraps
sizeBoot = 500; % Resampling size (bootci default is size(data))
alpha = 0.1;
n = numel(data);
bootMeans = mean(data(randi(n, sizeBoot, nBoot)));
interval = [alpha/2, 1 - alpha/2] * 100;
CI = prctile(bootMeans,interval)
CI = 1×2
27.6381 28.8684

请先登录,再进行评论。

回答(0 个)

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by