Thank you all! It works!
The new codes are:
mata:
M = st_matrix("M")
M = M[,7..16]'
lambda = J(cols(M), 4, .)
for(t=1; t<=cols(M); t++) {
mt = invvech(M[., t])
lambda[t, .] = symeigenvalues(mt)
}
lambda
end
By the way, does negative semidefinite require all the eigenvalues of
the matrix negative? Even one of them positive makes fail?
Jingjing
Quoting Glenn Goldsmith <[email protected]>:
Hi,
In addition to what Nick said:
1. I think that you want to be looping through the *rows* of your M matrix,
rather than the columns as you are trying to do now.
2. It doesn't look like you actually want all the rows of your M matrix as
it stands, you only want the last 10.
An *easy* way to achieve this (though not the most *elegant* way of
proceeding) would be to insert
M = M[,7..16]'
after the first line of your code.
M = st_matrix("M")
M = M[,7..16]'
lambda = J(cols(M), 4, .)
for(t=1; t<=cols(M); t++) {
mt = invvech(M[., t])
lambda[t, .] = symeigenvalues(mt)
}
HTH
Glenn.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/