I am using the fitnlm function, but for some data I am receiving this error - Error using nlinfit>checkFunVals The function you provided as the MODELFUN input has returned Inf

3 ビュー (過去 30 日間)
Hi,
I am using fitnlm function to find a non-linea fit for sets of data. This is the function handle: F = @(b,mu)((mu.^(2*b(2)-1)).*exp(4*b(1)*(log(mu)).^2 + b(3)));
mu is an array ranging from 0.3 - 0.9, and the value of b changes per iteration (the function is within a loop) with the range of b(1): 0.01 - 0.03, b(2) = 0 - 1, b3 = 0 -100. The function works for some iterations but not for others. If you plug the values into the function manually, it is all fine.
The error I am recieving is "Error using nlinfit>checkFunVals The function you provided as the MODELFUN input has returned Inf" within "Error in nlinfit>LMfit (line 596)"
if funValCheck && ~isfinite(sse), checkFunVals(r); end
if you plug the values into the function manually, it is all fine. Warnings also appear for some iterations like:
"Warning: Some columns of the Jacobian are effectively zero at the solution, indicating that the model is insensitive to some of its parameters. That may be because those parameters are not present in the model, or otherwise do not affect the predicted values. It may also be due to numerical underflow in the model function, which can sometimes be avoided by choosing better initial parameter values, or by rescaling or recentering. Parameter estimates may be unreliable. " & "Warning: Rank deficient, rank = 0, tol = 0.000000e+00."
Please could someone help?
Thanks,
Josh
  4 件のコメント
Joshua
Joshua 2024 年 1 月 17 日
With the exact same data, the same iteration could work one time and not the other
Torsten
Torsten 2024 年 1 月 18 日
Try whether
F = @(b,mu) b(3)*mu.^b(2).*exp(b(1)*(log(mu)).^2)
instead of
F = @(b,mu)((mu.^(2*b(2)-1)).*exp(4*b(1)*(log(mu)).^2 + b(3)));
works better.
It's easy to deduce the parameters of the original equation once you can solve the modified one.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by