필터 지우기
필터 지우기

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

조회 수: 13 (최근 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