Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: RE: use Mata to calculate the eigenvalues of the matrix


From   "Glenn Goldsmith" <glenn.goldsmith@gmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: use Mata to calculate the eigenvalues of the matrix
Date   Sun, 8 Mar 2009 20:11:02 -0000

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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index