How to avoid complex eigenvalues of the matrix in its non-linear regression? (lsqcurvefit)

8 次查看(过去 30 天)
Hi, I am working on fitting my data (X,Y) to a theoretical model of ten unknown parameters (to be optimized). I am using nonlinear regression by lsqcurvefit, where for given X(j)(each data point of X) the output of the function is one of the eigenvalue of a 4x4 (nonsymmatric but real elements matrix). e.g.
function y=funct_name(parameters,X,Y)
y=[]
for j=length(X);
L=eig([a+b*exp(X(j)*b),c*b*exp(X(j)*c)....;c+a*exp(X(j)*b)....]); %a,b,c etc are parameters
y=[y,L(2)];
end
y(output)=L(2);
Now the problem is that for given initial values of parameters (a,b,c.. etc) I am getting imaginary values of eigenvalues as well as of the parameters. I have tried changing intitial parameters but it doesn't seem to be working much. Is there any way to avoid complex values in the output of function. Also my function seems to be not going through many iterations, for which I tried changing step size (by optimset) but it changes the algorithm to trust region reflective by itself. However I want to use levenberg-marquardt only. Thanks

采纳的回答

John D'Errico
John D'Errico 2017-1-14
Eig returns complex eigenvalues because the matrix has complex eigenvalues. This is not an eig problem, or anything you can control using eig.
You need to consider why a matrix has complex eigenvalues. Generally, complex eigenvalues will not result for symmetric matrices, but there are other non-symmetric matrices with real eigenvalues.
Finally, using the second eigenvalue of a matrix as returned by eig is a foolish thing to do. Eig does not guarantee to always generate the eigenvalues in the same order. So always taking the second eigenvalue will potentially create a function that is poorly posed, and even non-differentiable. That would of course cause the solver to fail miserably, perhaps one of the problems you have.
  3 个评论
John D'Errico
John D'Errico 2017-1-14
编辑:John D'Errico 2017-1-14
No. eig is all there is.
You can sort the eigenvalues in descending order. But if you get complex eigenvalues, sort works on the magnitude of the numbers, so be careful.
Or, you can use my eigenshuffle code (on the file exchange), which tries to consistently reshuffle the eigenvalues and eigenvectors from a sequence of eigenvalue problems.
Vipultomar
Vipultomar 2017-1-14
okay.. I got the idea about descending order thing.. also some hint from this function by Calvin Price:
Reading into the eigenshuffle function now.
Thanks for the headsup about order of eigenvalues.
On the other hand, about complex eigenvalues, I guess it's all about initial parameters. So I'm gonna try giving initial parameters via some loop (starting from my initial guess and then small increment near where I expect my parameters to be.)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by