I am fitting my data with 'lsqcurvefit'. This works fine.
But now I would like to include a robust fitting procedure.
It was not clear to me from the help function whether or not
this is possible. In the section about robust fitting it is
written that on can use it for non-linear least square
problems. However I cannot find how to turn it on for my
function (here the options have to be set using 'optimset'
which does not like the option 'robust','on')
Ture
How can it be not clear in the help?
No place in the help for lsqcurvefit is the word
"robust" ever used. At least, find never located
the word, nor did quick a search I find that
word in any function in the entire optimization
toolbox. There is absolutely no implication that
this code is or can be used for anything but a
standard nonlinear least squares solution.
As far as using a non-existent 'robust' option
in optimset, you cannot simply make up an
option and pretend that it now is valid in
optimset. It is Monday. Can I now change the
day to last Thursday by setting
options = optimset('DayOfWeek','lastthursday');
While I admit that I've not tried this simple test,
it seems highly likely to fail.
You can find robustfit in the statistics toolbox.
John
> I am fitting my data with 'lsqcurvefit'. This works fine.
> But now I would like to include a robust fitting procedure.
Ture, depending on what toolboxes you have access to, you may be able to use
NLINFIT or ROBUSTFIT from the Statistics Toolbox, or FIT from the Curve Fitting
Toolbox.
Hope this helps.
- Peter Perkins
The MathWorks, Inc.
Dear John,
There is absolutely no need here to become sarcastic. In
fact, your answer is not helping anything.
First of all I am of course aware that the robust fitting is
not part of the optimization toolbox. However my question
concerned 'lsqcurvefit' which is part of the curve fitting
toolbox. In this toolbox you do have options for robust
fitting (e.g. the function 'fit', as also mentioned by Peter
Perkins).
I like 'lsqcurvefit' because it is extremely fast, has upper
and lower bounds and allows me to play with gradients and
hessians. The function 'fit' on the other hand is much
slower and if you want to fit a few ten thousand spectra you
do want to optimize the speed of the fitting routine.
'robustfit' and nlinfit are absolutely not suitable for my
purposes.
Concerning your comment about the help: maybe I am not a
genius as you are and yes, I do get sometimes lost in the
help functions of all these toolboxes (I have access to most
of them).
In the past I was actually using 'fminunc' and 'fminsearch'
from the optimization toolbox where I added myself the
robust part. But again here these routines are not really
fast and not optimized for complex curve fitting (e.g. no
upper and lower bounds).
I could somehow live with the 'fit' function but it is not
clear to me how to e.g. use a split pearsonVII (where the
function is defined by two separate equations).
So to cut long story short: what is actually the fundamental
reason that some functions have the option for robust
fitting and others don't?
Cheers!
Ture
Steven
Ture, part of the confusion is that lsqcurvefit is actually in the
Optimization Toolbox, even though its name sounds like it might be in the
Curve Fitting Toolbox.
The lsqcurvefit function has no built-in robust support, and I don't see a
good way to trick it into doing a robust fit. You might want to try the
lsqnonlin function instead. It expects your function to return a vector of
residuals directly (rather than fitted values). You could perhaps write
your function to return weighted residuals, with the weights chosen to
downweight outliers.
-- Tom
Dear Steven,
I read that you used fminunc to do robust fitting. If you
have the R2008A of the optimization toolbox, you might also
try ktrlink that uses the knitro solver.
If needed, I can provide you with a one-month trial license
of knitro for matlab.
Nicolas Omont
You can get a demo from here as needed: http://tomopt.com/scripts/register.php
Of course you can also use TOMLAB /KNITRO with slsSolve and MAD
(automatic differentiation) to get good results as well.
Best wishes, Marcus
Tomlab Optimization Inc.
http://tomopt.com/tomlab/