performing linear regression fits using cftool based on data points

I want to use the MATLAB curve fitting tools (cftool) to prediction intervals (compute 95% prediction intervals about th linear regression). I want to implement the following example problem for prediction intervals at x = 500 based on 13 data points and a linear regression fit.
(from J. Devore, Probability and Statistics for Engineering and the Sciences, 7th Ed., Brooks/Cole, Belmont, CA 2009, page 446)
x = [398 292 352 575 568 450 550 408 484 350 503 600 600]
y = [0.15 0.05 0.23 0.43 0.23 0.4 0.44 0.44 0.45 0.09 0.59 0.63 0.6]
Something like?

 채택된 답변

Sam Chak
Sam Chak 2022년 5월 9일
Does it look like this?
x = [398 292 352 575 568 450 550 408 484 350 503 600 600];
y = [0.15 0.05 0.23 0.43 0.23 0.4 0.44 0.44 0.45 0.09 0.59 0.63 0.6];
[~, idx] = sort(x);
ysort = y(idx);
xsort = x(idx);
mdl = fitlm(xsort, ysort)
plot(xsort, ysort, 'o')
grid on
xlabel('x')
ylabel('y')
hold on
xfit = linspace(min(xsort), max(xsort), 13);
yfit = 0.001432*xfit - 0.3115;
plot(xfit, yfit, 'r', 'linewidth', 1.5)
hold off

댓글 수: 2

Looks good to me, I was wondering if I can recreate this red and blue dashed lines in MATLAB
If you know the formulas for the 95% Confidence Interval and 95% Prediction Interval, then it is possible to plot the blue and red dashed curves. Follow my code (before the hold off line) and insert the formulas given here:
yCI = ...;
yPI = ...;
plot(xfit, yCI, '--b', 'linewidth', 1.5)
plot(xfit, yPI, '--r', 'linewidth', 1.5)
hold off

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

질문:

2022년 5월 9일

댓글:

2022년 5월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by