I am using the @eigenvalues() and @eigenvectors() functions and have a question regarding how their outputs are ordered. I am using EViews version 9.5.
Quoting the EViews manpages for @eigenvectors,
I would like, instead, to have the eigenvalues arranged in descending order by absolute value, and the columns of the eigenvector matrix correspond to the newly sorted eigenvalues."The eigenvalues are arranged in ascending order, and the columns of the eigenvector matrix correspond to the sorted eigenvalues."
Could a demonstration please be provided? Fundamentally, it's a problem about rearranging the columns of a matrix according to an indexing scheme.
For example, suppose I have a symmetric matrix called sym1.
Code: Select all
' Solve eigenvalue problem
vector evals = @eigenvalues(sym1)
matrix evecs = @eigenvectors(sym1)
' Sort eigenvalues in descending order by absolute value
vector evals2 = @sort(@abs(evals),"d")
' Sort columns of the eigenvector matrix to correspond to the newly order eigenvalues
' Insert code here Code: Select all
vector idx = @ranks(evals2, "a", "i")
matrix evecs2 = @rapplyranks(evecs,idx)For example, if one of the eigenvalues was negative, the @abs() function would, in effect, multiply this by negative one. I require the same transformation to be applied to the corresponding columns of the eigenvector matrix. How do I achieve this?
Graeme
-- Ah! I think I have it, I can just use something like @egt(evals,@zeros(@rows(evals))) and go from there. But, does seem like overkill!?
