Curve fitting confidence intervals - discrepancy in manual CI plot and predint plot

Hello friends, I am trying to find 95% CI on the fitted coefficients. The code I used is as follows(not the actual fitting function):
fo = fitoptions('Method','NonlinearLeastSquares');
myfittype = fittype('ax + b', 'dependent',{'y'}, 'independent', {'x'}, 'coefficients',{'a','b'});
[myfit,res] = fit(x,y,myfittype,fo);
fit_params = coeffvalues(myfit);
ci = confint(myfit,0.95);
To plot the CIs, I plug in the values of a and b from confint output to the original equation y = ax + b.
However, this CI is different from when I use plot(myfit,'predobs'). I am not clear on why this is so even after reading the MATLAB literature. Also, what is predint and how is this different from manually plotting the CIs as I did?
My main goal in the fitting is find what is the 95% interval in which a and b lies. Any help will be appreciated. Thank you.

 Akzeptierte Antwort

Matt J
Matt J am 16 Mär. 2026 um 0:42
Bearbeitet: Matt J am 16 Mär. 2026 um 14:29
Also, what is predint and how is this different from manually plotting the CIs as I did?
predint predicts an uncertainty interval for y, not for a and b. As the others have said, it seems you tried to use some ad hoc method of your own (one whose details are not clear to us) to derive confidence intervals on y from confidence intervals on a and b. That is not normally what is done, and in fact, usually it goes the other way around: you start with an uncertainty estimate on y and then try to derive confidence intervals on a and b from that.
My main goal in the fitting is find what is the 95% interval in which a and b lies.
If so, it is unclear why we are talking about predint, predobs, or even plotting at all. Your "main goal" was achieved once you ran confint.

1 Kommentar

Thank you everyone and Matt. I was just looking for the C.I.'s of the coefficients. Took me some time to realize.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Torsten
Torsten am 15 Mär. 2026 um 21:20
Bearbeitet: Torsten am 15 Mär. 2026 um 22:13
Did you read
?
The formulae to compute the different prediction bounds are listed here.
95% prediction bounds on the parameters are computed correctly in your code as ci = confint(myfit,0.95).
95% prediction bounds on the fit are different from simply plugging in the bounds a_low, b_low, a_high, b_high for a and b from confint and computing a_low*x + b_low and a_high*x + b_high for a given x ( I guess that's what you meant by "To plot the CIs, I plug in the values of a and b from confint output to the original equation y = ax + b." )

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 15 Mär. 2026 um 20:58

Kommentiert:

am 21 Mär. 2026 um 19:14

Community Treasure Hunt

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

Start Hunting!

Translated by