When using the cftool, should I use Trust Region or Levenberg-Marquardt?
Show older comments
Hello,
I have a data-set that behaves like a sin wave. I need to fit a curve to the data-set using the cftool. In the fit options, there are two algorithms I can choose from: 'trust-region' or 'Levenberg-Marquardt'.
I am trying to figure out the difference between the two algorithms, which algorithm is better, and why. Below is my code, and a screenshot of the curve fitting tool as well as my fit options. Thanks in advance.
%Who: Wesley Brown
%Input: PPP orthometric heights
%Process:Curve fitting
%Output: a1, a2, etc.
clear
format longg
%Time matrix in days
x = [0
90
180
270
360
450
540
630
720
810
900
990
1080
1170
1260
1350
1440];
%Y matrix (change in orthometric height from day 1)
y = [ 0
0.00799999999998136
0.007000000000005
0.00799999999998136
0.000999999999976353
-0.0010000000000332
0.0129999999999768
0.0149999999999864
0.0109999999999673
0.00200000000000955
0
0.0029999999999859
-0.007000000000005
0
-0.00300000000004275
0.00200000000000955
-0.0080000000000382];
cftool(x(:,1),y(:,1));


5 Comments
Walter Roberson
on 22 Jan 2020
Notice that your a1 coefficient has a confidence interval that crosses 0 and is roughly as negative as positive. Most of the time when you see a coefficient with confidence interval as negative as positive, the value for the coefficient is garbage, with the fitting being unable to decide between two basins of attraction.
You can try working in two steps, one with a1 constrained to be negative, and then again but constrain it to be positive, and then compare the two outcomes.
What you have now is a fairly poor fit. It is not obvious to me that the model has any relevance to the data.
Wesley Brown
on 22 Jan 2020
Walter Roberson
on 22 Jan 2020
In the Fit Options section, those Lower and Upper are editable.
Walter Roberson
on 22 Jan 2020
Edited: Walter Roberson
on 24 Jan 2020
I am not able to answer the question of which is better or why. The algorithms are described at https://www.mathworks.com/help/optim/ug/equation-solving-algorithms.html
With the data and model you have, your question is like asking whether a chicken or a platypus is a better approximation for a snake.
Walter Roberson
on 24 Jan 2020
You can get a slightly better fit near
5.84357338824362e-05 2.58183128710864e-05 0.00521135858653424 -0.199178847293523 0.678796516975015 -2.289596742701e-08
These parameters are not unique! The sign of the 3rd one can change, and the 5th one involves semi-periodic behavior about pi/180 apart. The 4th one is periodic as well...
It is still a pretty ugly fit. The model is a terrible one for explaining the data.
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!