Parameter estimation nlinfit vs. fitnlm

Hi
I want to fit a nonlinear model using nonlinear regression function nlinfit or fitnlm.Is there a difference? which one is more robust for a difficult kinetic model?
It seems both use Levenberg-Marquardt algorithm ?
Thank You,

 Accepted Answer

There is no real difference. Both nlinfit and fitnlm are Statistics Toolbox functions for nonlinear regression, and so use the same fundamental functions. The fitnlm function is a shell around nlinfit and its friends. The advantage to fitnlm is that it’s slightly easier to use, and delivers a few more statistics. The important results — parameter confidence intervals and confidence intervals on the fitted equation — are easy to get with either, but actually slightly easier with nlinfit, nlparci and nlpredci.
Experiment with both, and see which is most appropriate to your application.
Don’t neglect lsqcurvefit if you have access to it (Optimization Toolbox). It can do two things that the Statistics Toolbox functions cannot: (1) accept bounds on the parameters, and (2) fit matrix dependent variables. It doesn’t have access to all the statistics the Statistics Toolbox functions do, but it definitely has its uses.

7 Comments

Thank you! So based on what you said lsqnonlin or lsqcurvefit seem to be more suitable for me but one more question here: if my objective model is in the form :
(X(measured)-X(predicted)^2 and the parameters that I want to estimate is not explicitly shown in X(predicted), but shown in another function that evaluates the X(predicted); would this be an acceptable input for lsqnonlin or lsqcurvfit?
My pleasure!
All the nonlinear solvers ( nlinfit, lsqcurvefit ) incorporate the objective function, so you only need to provide them with your model function, independent and dependent variable data, and whatever other options you may find necessary. Read up on the various options functions and structures for the various solvers. The options structures allow you to vary tolerances, number of function evaluations, iterations, and other characteristics.
So, is there no way to put lower and upper bound with fitnlm? I need to use this function, instead lsqnonlin, because I have more statistics. How could I add my bounds? Thank you
The Statistics and Machine Learning Toolbox function fitnlm does not permit parameter constraints (at least in R2017b and prior versions). You must use the Optimization Toolbox lsqcurvefit function (or similar functions) for bounded parameters. Parameter confidence intervals, and other such statistics on models with bounded parameters, are likely not reliable. I am not certain it is even possible to calculate them.
Oh, ok. Thank you!
Hi, can I know other than lsqcurvefit (same as lsqnonlin ?) and nlinfit. Are there any other suggestions on fitting a nonlinear data ? Mainly, I would like to compare how well different methods could do. Many Thanks

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!