필터 지우기
필터 지우기

How can I avoid the negative results from nlinfit function?

조회 수: 9 (최근 30일)
Amjad
Amjad 2013년 5월 11일
댓글: John D'Errico 2017년 3월 15일
How can I avoid the negative results from the nlinfit function? Some articles advice to use lsqcurvefit but how and where, I don't understand?
thankx a lot

채택된 답변

Matt J
Matt J 2013년 5월 12일
편집: Matt J 2013년 5월 12일
LSQCURVEFIT allow you to specify upper and lower bounds on the parameters via the ub and lb input arguments. I can't tell if NLINFIT lets you do the same. You could also try a transformation of your parameters that ensures positivity, i.e., instead of making your model a function of a parameter x, make it a function of x=z^2 and fit with respect to z.
  댓글 수: 5
Matt J
Matt J 2017년 3월 15일
Not with lsqcurvefit. You can pose the fitting as a non-linearly constrained optimization problem and solve with FMINCON. However, bound constraints lb<=f()<=ub on a nonlinear function f can give feasible regions that are not connected and therefore, difficult to optimize over.
John D'Errico
John D'Errico 2017년 3월 15일
Matt is completely correct here. I'll add that one common reason for needing a positive result is that your model is really not subject to additive Gaussian noise. This is the presumption for nlinfit, as well as many other tools like lsqnonlin, etc.
When you have the above problem, it may indicate that you have proportional (multiplicative) noise. The trick then is to log your model. So instead of trying to fit a model in the form
y = f(X,P)
you fit a model of the form
log(Y) = G(X,P)
where G is simply log(F).
The nice thing is now your predictions are entirely positive, ALWAYS. This is true because at the end, you will predict Y as exp(G(X,P)). You can still use standard tools like nlinfit, lsqcurvefit, etc. Effectively you have a noise structure that is lognormal, instead of the traditional additive normal noise.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by