MATLAB Answers

1

Fit function versus lsqcurvefit

Asked by thatguy14 on 21 Oct 2015
Latest activity Commented on by dpb
on 22 Oct 2015
Hello,
this hopefully will be a quick question/answer. I am curious as to the difference between the "fit" function and the "lsqcurvefit" function. I ask this because for "fit" you can specify any model using an anonymous function (among other methods). For example, if I have a function that involves a convolution with some parameters in it that need to be fit, can I use the "fit" function or do I have to use the lsqcurvefit?
Appreciate the response.

  0 Comments

Sign in to comment.

1 Answer

dpb
Answer by dpb
on 21 Oct 2015

It's your choice; fit is a wrapper around a whole bunch of stuff to try to make a general interface for the Curve Fitting Toolbox whereas lsqcurvefit can be thought of as a "lower-level" function for direct access that's in the Optimization Toolbox. Another case where there's duplicated abilities with an initially somewhat different target audience that ends up in questions like this of "why?"...and, of course, there's no direction from TMW as to where one would choose one or t'other if do have both.

  2 Comments

I was pretty sure it was a wrapper as you said but I wasn't totally sure because I didn't see anything in the documentation (thought maybe I missed something). Awesome then, I will use fit. Actually, there is another function called nlinfit that if called can provide a variance covariance matrix. Do you know if there is any way to get the covaraiance between the fitted variables using the fit method?
dpb
on 22 Oct 2015
Not from fit, no. Again, TMW tends to do well on computations but the outputs from the toolboxen don't always (usually?) live up to what one would like in both all information of interest and particularly, imo, lack of prepared output formatted tabular data for the investigator/researcher who isn't so much interested in programmatically continuing to further manipulate data buried in some output structure to derive these results but would far prefer they be available certainly but that they be presented in a clear and meaningful way without extra effort for consideration and from which to draw conclusions. SAS is far better in that regard and would serve as a useful model to TMW to tend to emulate.
I think the closest piece of information you can get that leads you on the start to the calculation is that the Jacobean is saved.

Sign in to comment.