performing linear regression fits using cftool based on data points
2 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
採用された回答
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 件のコメント
Sam Chak
2022 年 5 月 9 日
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 件)
参考
カテゴリ
Help Center および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!