Confidence interval for slope and intersect using bootstrapping

1 vue (au cours des 30 derniers jours)
Emma
Emma le 12 Avr 2017
Réponse apportée : OCDER le 28 Sep 2018
Hi!
I have 2 variables with some NaNs. I use bootstrapping to get the slope and intersect from a linear regression:
good = isnan(var1) + isnan(var2);
p_bootstrp = bootstrp(1000, 'polyfit',var1(good == 0),var2(good == 0),1);
med_slope = median(p_bootstrp(:,1)); % The slope
med_intersect = median(p_bootstrp(:,2)); % The intersect
But, I cannot figure out how to get the confidence intervals for this using bootci. I thought that I could use bootci the same way as when getting a confidence interval for the corelation coefficient but that doesn't work.
ci_slope = bootci(5000, @polyfit, var1(good == 0), var2(good == 0));
How do I calculate the confindence interval for linear regression using bootstrapping? Is there a Matlab function to do it?
Thanks,
Emma
  1 commentaire
Aidan Starr
Aidan Starr le 28 Sep 2018
Hi Emma,
Not sure if I'm missing something, but looks like you just need to include the order for polyfit to work.
ie:
ci_slope = bootci(5000, @polyfit, var1(good == 0), var2(good == 0),1);
Hope this helps, Aidan

Connectez-vous pour commenter.

Réponses (1)

OCDER
OCDER le 28 Sep 2018
I believe it's just the percentile itself for bootstraps. If you get 1000 bootstrapped sample and results, then take the top 2.5% for the upper bound, bottom 2.5% for the lower bound, and you get your 95% CI.
% 95% CI means 2.5% bottom and top
LowerCI = prctile(p_bootstrp, 2.5, 1); Lower Slope, Lower Intersect
UpperCI = prctile(p_bootstrp, 97.5, 1); Upper Slope, Lower Intersect
To get an exact CI, you need to find the actual values and recompute the CI (just more details)
See Page 5

Community Treasure Hunt

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

Start Hunting!

Translated by