How to compute the slop of bootstrap population with its confidence interval?

5 views (last 30 days)
Hi everyone,
I read through all the documentions and avaible function of Bootsrap in matlab most of them compute the mean or correlation of each iteration. However, i need to compute the slop of bootstrap population. For example:
My data set consist of around 50 observations, i like to randomly pick 100 observations with replacmenet for 2000 bootstrap iterations. For each iteration, i require to compute the slop and eventually, i will get 2000 slop observations. Then i need to compute the 95% confidence interval of these observations.
May someone suggets me how i can do this:
Here is a simpel start:
A = [0.045494, 0.065669, 0.073061, 0.104542, 0.296978, 0.498353, 0.503342...
0.515458, 0.660300, 0.663664, 0.677255, 0.724817, 0.805800, 0.899355...
0.987775, 2.121619, 2.165055, 2.196833, 3.265653, 3.479858, 8.702472 ...
10.070092, 10.720080, 12.896169, 12.912647, 14.24436,1 14.287428, 17.337397, 18.903783, 20.940314, 21.404639, 22.234169]
% A is the data
m = bootstrp(100,@mean,A);
  2 Comments
Andi
Andi on 15 Aug 2022
For slope, we use number of observations as X and Y is the bootstrap population. For example, if we set bootstrap population 30 then the x is 1, 2, 3... 30,
Regarding the second, point, I think it be good for me to test both approaches, and see how it effect my analysis.

Sign in to comment.

Answers (1)

Jeff Miller
Jeff Miller on 16 Aug 2022
Edited: Jeff Miller on 16 Aug 2022
It sounds like this is what you are after, although I'm not sure why you want to do it:
m = bootstrp(100,@mySlope,A);
LowerCI = prctile(m,2.5); % lower / upper bounds for 95% conf interval
UpperCI = prctile(m,97.5);
function slope = mySlope(Yvals)
Xvals = 1:numel(Yvals);
P = polyfit(Xvals,Yvals,1);
slope = P(1);
end

Categories

Find more on Time Series in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!

Translated by