Wrong area filled with fitlm confidence interval
Show older comments
Hello,
I have extracted the confidence interval from some data interpolated with the linear interpolation function in Matlab through the following commands:
mdl = fitlm(x_data, y_data);
x_data and y_data are column vectors with shape 43x1.
From which I have extracted the confidence interval:
[yhat1,ci1] = predict(mdl,x_data)
I want then to fill the area within the confidence interval and I have tried the following commands:
xconf = [x_data x_data(end:-1:1)];
yconf = [ci1(:,2) ci1(end:-1:1,1)];
yconf2 = [ci1(:,2) ci1(:,1)]
%First temptative
fill(xconf, yconf, 'red')
%Second temptative
fill(xconf, yconf2, 'red')
In both cases, the area which is filled is wrong (what is displayed is the confidence interval only):

I would like to ask some suggestions how to solve this problem having the confidence interval extracted with the linear interpolation function.
Thank you!
Accepted Answer
More Answers (0)
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!