Choosing a method for nonlinear data-fitting to find parameters

I'm currently trying to fit nonlinear experimental data to find two parameters. Using lsqcurvefit has been working well about 90% of the time, but I wanted to try to improve that. I have found other methods for fitting data, but I'm confused about the differences between them, and how to choose one. I tried using MultiStart in addition to lsqcurvefit, but that did not seem to improve the results. I also tried lsqnonlin without any luck. Do you have any recommendations about other methods/options to try? I have access to the majority of the toolboxes. Some people were discussing the use of robustfit, but I was confused about the implementation of that. Any insight would be greatly appreciated!

 채택된 답변

Matt J
Matt J 2017년 7월 31일
편집: Matt J 2017년 7월 31일

1 개 추천

If lsqcurvefit is failing and your objective function is legal (differentiable, etc...), then it must be that you are deriving a bad initial guess in those failure cases. Since it is only a 2 parameter search, you should be able to derive a good initial guess of the optimum just by evaluating the least squares cost function on some coarse grid and either plotting them as a 2D surface or taking the minimum over the samples.

댓글 수: 6

Knowing the model itself would be of great importance, and some tools will not be even appropriate for some models.
For example, if you can formulate the model in a form admissable for a tool like my fminspleas, that will often greatly improve the robustness of the fitting process.
Nik
Nik 2017년 7월 31일
편집: Nik 2017년 7월 31일
Matt, is there any way you can elaborate on the least squares cost function? I don't really have much experience with this, and I haven't been able to find a clear explanation of it online. Thanks!
John, the equation is y = A*(1-exp(-B*t) and all of the data, including the data that don't fit as well, follow a logistic curve for the most part.
lsqcurvefit looks for parameters x that minimize
cost(x) = norm(F(x,xdata)-ydata).^2
You could plot cost(x) as a 2D surface and look for where the minimum approximately occurs. Also, now that we see your model equation, I agree with John that fminspleas would work well for this problem: you only have one non-linear parameter, B.
fminspleas will be more efficient here, as well as more robust, because it need to work with only the one nonlinear parameter, B. That means A does not need a starting value, nor is it really solved for in an iterative sense. This also makes the problem more robust, because the parameter search is now done in a 1-dimensional search space, instead of the 2-d space of the original problem.
You can even take advantage of the model form to use the expm1 function, since expm1(X)=exp(X)-1. This can be more accurate for some values of X. I doubt it is important here though.
funlist = {@(B,xdata) -expm1(-xdata*B)};
Thank you both so much! I tried using fminspleas, and I did notice a little improvement.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Yahya Zakaria mohamed
Yahya Zakaria mohamed 2017년 8월 1일

1 개 추천

You can use the APP for curve fitting.
<<
>>
It fits very well with about 95% I think nothing more You will get.You can generate code from the app and modify it as You wish.

댓글 수: 1

Thank you, I didn't realize that code can be generated from the tool.

댓글을 달려면 로그인하십시오.

질문:

Nik
2017년 7월 31일

댓글:

Nik
2017년 8월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by