Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

nlinfit, lsqcurvefit and fitting procedure

179 views
Skip to first unread message

Alessandro

unread,
Apr 14, 2009, 5:10:03 AM4/14/09
to
Hi All,
I'm trying to fit a data set with a nonlinear implicit function F(beta,X,Y).
I'm not sure whether I should carry out a fit using nlinfit or lsqcurvefit.
They both works and give practically the same results.
Looking at the description of nlinfit there is no mention about how the non-linear regression is carried out, while with lsqcurve fit I have a lot of possible techniques that I can choose from. In this sense nlinfit seems to be really a blackbox to me.

I thought regression was a more general concept that least square, maybe I'm missing the difference between the two. Can anybody help me in finding the way through?

However, I do not only to fit some parameters but I would also like to have their covariance and the uncertainty on the predicted value. For this purpose nlinfit seems to be better as I can use "nlpredci".
With lsqcurvefit I can also get the covariance via the jacobian. On the other hand I have to workout the uncertainty on Y which requires more work.
Any help on this issue would be really appreciated.

Thanks,
Alessandro

Peter Perkins

unread,
Apr 14, 2009, 11:07:39 AM4/14/09
to
Alessandro wrote:

> I'm trying to fit a data set with a nonlinear implicit function F(beta,X,Y).
> I'm not sure whether I should carry out a fit using nlinfit or lsqcurvefit.
> They both works and give practically the same results.
> Looking at the description of nlinfit there is no mention about how the non-linear regression is carried out, while with lsqcurve fit I have a lot of possible techniques that I can choose from. In this sense nlinfit seems to be really a blackbox to me.

Alessandro, NLINFIT uses a standard Levenberg-Marquardt least squares algorithm, essentially the same as one of the two algorithm choices in LS.

The first line of the help says

BETA = NLINFIT(X,Y,MODELFUN,BETA0) estimates the coefficients of a
nonlinear regression function, using least squares estimation.

which does describe exactly what kind of regression the function does, i.e., what _criterion_ it uses. Which _algorithm_ it uses is what's missing, and I've made a note to have that added to the documentation.

Alessandro

unread,
Apr 15, 2009, 2:02:08 AM4/15/09
to
Thank you,
indeed it would be worth to describe better nlinfit.
I don't understand why there are 2 functions that do the same thing.
The only difference seems to be in the options and in the format of the output.
Wouldn't it be better to unify the 2 functions?

Peter Perkins <Peter....@MathRemoveThisWorks.com> wrote in message <gs28rr$ejm$1...@fred.mathworks.com>...

Peter Perkins

unread,
Apr 15, 2009, 9:20:59 AM4/15/09
to
Alessandro wrote:
> Thank you,
> indeed it would be worth to describe better nlinfit.
> I don't understand why there are 2 functions that do the same thing.
> The only difference seems to be in the options and in the format of the output.
> Wouldn't it be better to unify the 2 functions?

One reason that may not be very compelling for you is that NLINFIT and LSQCURVEFIT are in two separate toolboxes (Statistics and Optimization), which explains why one is aimed more at a statistical application. Another difference between the two is that LSQCURVEFIT allows bounds on the parameters.

0 new messages