How to computing confidence bounds of the regression model using the bootstrap method

5 views (last 30 days)
I would like to compute and plot the bootstrap confidence bounds of the non-linear regression model. I have computed the bootstrap confidence intervals of the coefficients and now I want to visually display the confidence bounds. In other words, I would like to have something similar to the red dotted lines in this figure
Here is what I have done so far.
modelfun = @(b,t)( 100*b(1).*exp(-b(3).*(1-exp(-b(4).*t))./b(4)-b(2).*((exp(-b(4).*t)-1+b(4).*t)./b(4).^2)) );
b=[1.0190; 2.2297e-5; 6.668e-13; 8.3576e-6];
t=exprnd(2,100,1);
y = modelfun(b,t) + normrnd(0,0.1,100,1);
beta0 = [1; 0.0001; .0000000001; .000001];
beta = @(predictor,response)nlinfit(predictor,response,modelfun,beta0);
newci = bootci(100,{beta,t,y},'Alpha',0.01)
I do not know how to proceed from here.
I appreciate any insights that can help me solve my question. Thanks
  1 Comment
Editor
Editor on 27 Oct 2022
Since I posted the question, I have not received any feedback from the community. Could it that my question is not clear? Can someone kindly advise.

Sign in to comment.

Accepted Answer

Jeff Miller
Jeff Miller on 28 Oct 2022
I'm assuming that your figure shows t on the horizontal axis and y on the vertical.
The problem is that bootci is giving you confidence intervals for the parameter values but what you really want (judging from the figure) is confidence intervals for the predicted y values at each t.
I think you can get those but it will be more work. You will have to use the bootstr function to generate bootstrap datasets, fit the model to each dataset, and then generate the predicted y values at each of a preselected set of t's for each bootstrap iteration. Then, after lots of iterations, you can look at the small and large (2.5% and 97.5%ile) y values that you generated for each t separately. Plotting the small ones vs t should give you your lower dotted line, and large versus t the upper.
I hope this is what you were asking for...

More Answers (0)

Community Treasure Hunt

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

Start Hunting!