When using the cftool, should I use Trust Region or Levenberg-Marquardt?

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 comentarios

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.
Thank you for your input Walter. That is clearly something else I need to pay attention to. But this does not answer my question above. Are you able to answer my question above? Also, how do I constrain a1 to be positive or negative?
Thanks
In the Fit Options section, those Lower and Upper are editable.
Walter Roberson
Walter Roberson el 22 de En. de 2020
Editada: Walter Roberson el 24 de En. de 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.
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.

Iniciar sesión para comentar.

 Respuesta aceptada

Matt J
Matt J el 22 de En. de 2020
Editada: Matt J el 22 de En. de 2020
You can read here about the relative limitations of the 2 algorithms,
For you, I expect the decision on which algorithm to use will depend on whether you wish to impose bounds on the parameters. Levenberg-Marquardt does not handle bound constraints. It's not really even a decision. If you try to impose bounds, cftool will default to the trust-region algorithm.

2 comentarios

This is great thank you so much! Cheers
You are welcome, but please Accept-click the answer if it addresses your question.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 22 de En. de 2020

Comentada:

el 24 de En. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by