Borrar filtros
Borrar filtros

Speed up Block Stationary Bootstrap

3 visualizaciones (últimos 30 días)
Ricardo Henriquez
Ricardo Henriquez el 18 de Jul. de 2023
Respondida: Keshav el 26 de Jul. de 2023
Hello,
I am currently working with Kevin Sheppard's block bootstrap code for my project, but I've noticed that it becomes slow for bootstraps exceeding 10^6. I'm looking for suggestions on how to optimize and speed up the code, possibly through parallelization or other techniques. Your expertise and insights are highly appreciated. Thank you!
Slide 34.
n = 300; y = randn(n,1);
T=size(y,1);
% Average block size
m = 10;
%Nbootstraps
B = 10^6;
% Loop over B bootstraps
yRepl = [y;y];
u = zeros(T,1);
tic
for b=1:B
u(1) = ceil(T*rand);
for t=2:T
if rand<1/m
u(t) = ceil(T*rand);
else
u(t) = u(t-1) + 1;
end
end
% y-star sample simulation
yStar = yRepl(u);
% Mean of y-star
muStar(b) = mean(yStar);
end
toc
I've tried a parfor-loop but I am getting the following error on u.
Unable to classify the variable 'u' in the body of the parfor-loop. For more information, see Parallel for Loops in MATLAB, "Solve Variable Classification Issues in parfor-Loops".

Respuestas (1)

Keshav
Keshav el 26 de Jul. de 2023
Hi,
You can look at the below MathWorks documentation to resolve the error you are getting while using the ‘parfor-loop’.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by