Curve Fit fixed at bounds problem
41 views (last 30 days)
Show older comments
Sarabjeet Seehra
on 10 Apr 2016
Commented: Walter Roberson
on 22 Feb 2023
Hello,
I have been having problems trying to fit the following function to my given data:
sqrt(a).*(2 .* b .* exp(-b .* x)) + sqrt(1-a) * (.204124145*(D).^(5/2)* x *exp((-D)*x*(1/2)))
The data in use was generated using the following function, with x values from 0 to 10 with 0.1 steps:
y=-.047833878*exp((-18.7311370)*(x + .7199811451).^2)+ -.081134269*exp((-2.8253937)*(x + .7199811451).^2) + -.092369697*exp((-.6401217)*(x + .7199811451).^2) + -.148487297*exp((-.1612778)*(x + .7199811451).^2)+ (.011189936*x + .008056543) .* exp((-1.1)*(x + .7199811451).^2)+ .047833878*exp((-18.7311370)*(x - .7199811451).^2)+ .081134269*exp((-2.8253937)*(x - .7199811451).^2) + .092369697*exp((-.6401217)*(x - .7199811451).^2) + .148487297*exp((-.1612778)*(x - .7199811451).^2)+ (.011189936*x - .008056543) .* exp((-1.1)*(x - .7199811451).^2).
Then using Curve Fitting Tool, I have tried to fit the generated data to this function:
sqrt(a).*(2 .* b .* exp(-b .* x)) + sqrt(1-a) * (.204124145*(D).^(5/2)* x *exp((-D)*x*(1/2)))
Note that a has a range between 0 and 1, b has a range between 0 and 5, and D has a range also between 0 and 5.
When I finally tried to perform the non-linear least squares fit, I keep on receiving the following problem:
General model:
f(x) = sqrt(a).*(2 .* b .* exp(-b .* x)) + sqrt(1-a) * (.204124145*(D).^(5/2)
* x *exp((-D)*x*(1/2)))
Coefficients (with 95% confidence bounds):
D = 2.22e-14 (fixed at bound)
a = 0.08913 (0.08806, 0.0902)
b = 0.7275 (0.7214, 0.7337)
Goodness of fit:
SSE: 0.01507
R-square: 0.9928
Adjusted R-square: 0.9927
RMSE: 0.0055
Is there anyway that I can remove this fixed at bounds error? Thank you for your time.
0 Comments
Accepted Answer
Walter Roberson
on 11 Apr 2016
Yes, you could change the lower bound for D to be -inf. It appears to me that "fixed at bound" means that it has been driven as small as you permitted in your lb and tolerances together.
More Answers (1)
Leo Polak
on 14 Jan 2023
Edited: Leo Polak
on 14 Jan 2023
I think this result means that, although the fit result D is within range, the confidence interval is out of range. With more data or another fitting procedure you might be able to solve this. But if D is very close to a bound and the data doesn't determine the parameter accurately that might impossible. Probably, you could just set D to zero and that wouldn't change your fit significantly.
3 Comments
Leo Polak
on 22 Feb 2023
Thanks!
No, it means that no matter how small (positive) that you make D, you can get a smaller residue if you use a smaller (positive) D. That does not mean the confidence interval is out of range.
But, doesn't that mean that zero is the best fitting value? Why does it give this specific value, is that the best fitting value? And why is it not giving a confidence interval with it, is that not possible?
I actually have a similar situation, but when I set that fitparameter to zero I get a slightly poorer fit, the rsquare is bit lower, rmse is a bit higher, etc., which seems to contradict the idea that zero is the best fitting value and suggests that there is a non zero positive value that is the best fit.
Walter Roberson
on 22 Feb 2023
We can deduce from the message that when the original poster used the Curve Fitting Toolbox, that they used options to set the lower limit for D to
format long g
100*eps
and fit() did not go lower than that for D because a particular bound was requested.
It is not giving a confidence bound because all of its jacobian estimates say that D should go smaller than the bound the user requested. It cannot properly estimate the "correct" value for D because the calculations all say "smaller than the user permits".
See Also
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!