performing linear regression fits using cftool based on data points
1 次查看(过去 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 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!