MATLAB: How to plot prediction and confidence interval

confidence intervalCurve Fitting Toolboxlinear regressionprediction interval

Hi all,
I try to plot a prediction interval and a Confidence interval, of a linear regression fit. The prediction interval seem to be fine, but the confidence interval seems to be wrong. For the confidence interval I use ‘’ confint’’, see File.
Suggestions? Thanks a lot!!!
Matlab r2014a

Best Answer

p = predint(fitresult,x,0.95,'observation','off');
ci = confint(fitresult,0.95);
ciup = polyval( ci(2,:),x);
cilow = polyval(ci(1,:),x);
NO! ci ARE the confidence limits; they are bounds on the coefficients themselves, hence only an upper/lower for each of the N+1 coefficients. Remove the last two lines entirely; they're a total misuse of ci
All you can plot for them would be something like
errorbar([0 1],coeffvalues(fitresult),ci(1,:),ci(2,:),'x')