Nlinfit: Warning: The Jacobian at the solution is ill-conditioned, and some model parameters may not be estimated well (they are not identifiable). Use caution in making predictions.

69 visualizaciones (últimos 30 días)
I wrote a Matlab program for fitting some experimental data using nlinfit. The fit looks very nice but, Matlab returns the following warning : Warning: The Jacobian at the solution is ill-conditioned, and some model parameters may not be estimated well (they are not identifiable). Use caution in making predictions.
I cannot understand why and correct it. Could someone help me ? Thanks !

Respuesta aceptada

John D'Errico
John D'Errico el 8 de Abr. de 2016
Editada: John D'Errico el 8 de Abr. de 2016
Perhaps an example is simplest. In fact, I can give you a linear example that would probably cause the same error from nlinfit.
Consider the simple linear model:
z = b*x + c*y
Looks simple. Who could possibly complain?
x = randn(10,1);
y = x;
z = x + 2*y;
So I have a two parameter model, with 10 data points. I know in advance that I would EXPECT the coefficients to be [1,2].
But will nlinfit have a problem? Why would it have a problem? Look at the data that went into the problem. Given that x and y are identical, I could as easily have estimated the coefficients as [3,0], [0,3], [1.5 1.5], or [-5,8]. ANY of those sets of parameters will be equally valid. The result is the Jacobian matrix ends up as a singular one. I.e., it is ill-conditioned. If nlinfit DOES converge, I would hope it fails with the same error that you got, and for good reason. You cannot trust the coefficients.
So, the problem here is mainly with my data, in particular, how it relates to the model i have chosen. The model would be fine had my data been of sufficient quality to fit the model.
In your case, I do not have the model to look at, or the data that went into fitting the model. Lets try nlinfit out on my data with my model.
modelfun = @(beta,X) X*beta(:);
[BETA,R,~,COVB,MSE] = nlinfit([x,y],z,modelfun,[1,1])
Warning: The Jacobian at the solution is ill-conditioned, and some model parameters may not be estimated well (they are not identifiable). Use
caution in making predictions.
> In nlinfit (line 376)
BETA =
1.5 1.5
R =
4.4409e-16
1.7764e-15
-8.8818e-16
0
2.2204e-16
-8.8818e-16
-2.2204e-16
0
1.7764e-15
1.7764e-15
COVB =
9.8161e-33 9.8161e-33
9.8161e-33 9.8161e-33
MSE =
1.26e-30
So we got the same error that you did. The residuals are ZERO, or at least as close as MATLAB can come in floating point arithmetic. The MSE is zero. COVB is singular.
Essentially, the fit is great, as was yours. But it is not a good model for this data. Or the data is not good for this model. (Take your pick.)
Did we get the same solution as that we started with? NO. It is as good a solution. But it is different. There are infinitely many equally good solutions to the problem I posed. Should I trust the one I got? Of course not. And that is what nlinfit told you.
Your problem is likely similar. You may be trying to fit a model that is too complex for your data, one that is not supported by that data. This is often called overfitting. You may have a variety of numerical issues with the data that MIGHT result in the same error. You may just have poor data, as was the case that I created, where the data was simply insufficient to fit two parameters. For example, in the case I created, were I to recognize that x and y were identical, then I might have chosen to reduce the model to
z = a*(x+y)
So now one parameter to fit. This fit will also be perfect, with essentially zero residuals, but it will not generate any warning messages. The solution will be unique, with a==3. Everybody will be happy.
So, as I said, since I cannot see your data or your model, I cannot know "why" you got that warning message, in the sense that I do not know exactly what sin you have committed in creating this fit.
  9 comentarios
Alex Sha
Alex Sha el 12 de Nov. de 2021
Hi, the results I provided above had been obtained by 1stOpt, an package other than Matlab, with greate ability on global optimization.
Chinmayee L M
Chinmayee L M el 19 de En. de 2024
I am facing the same problem as Anna while using nlinfit. I am trying to fit a single exponential decay function to a noisy time series. I run into the error being discuss, while using nlinfit function. But, when I use fit function to fit the same data with the same exponential decay function, I do not see that error. Why is that? Are implementaions of the fit different? Which is better?

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by