# Re: st: AW: use Mata to calculate the eigenvalues of the matrix

 From jjc.li@utoronto.ca To statalist@hsphsun2.harvard.edu Subject Re: st: AW: use Mata to calculate the eigenvalues of the matrix Date Sun, 08 Mar 2009 14:51:11 -0400

```Hi,

Hi Martin,

```
I will use -mm_matlist() function from the moremata later, not now. Sorry about that.
```
My matrix can b computed as follows:

11
21  22
31  32  33
41  42  43  44

```
I used the coefs' point estimates available in ereturn list computed from 126 time-series observations and calculted the elements of matrix for each time period.
```
```
But the 126 obervations are composed of 7 regions, 18 years (7*18=126). Does it cause the problem?
```
Jingjing

Quoting Martin Weiss <martin.weiss1@gmx.de>:

```
```
<>

Where do you use -moremata- in your code? And are you sure that you are
passing a column vector to -invvech()-?

HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von
jjc.li@utoronto.ca
Gesendet: Sonntag, 8. März 2009 19:18
An: statalist@hsphsun2.harvard.edu
Betreff: st: use Mata to calculate the eigenvalues of the matrix

Dear All

I am tring to use Mata to calculate the eigenvalues of the matrix, but
there is some problems. First, I installed the moremata package by Ben
Jann. Then, when I type:

mata:
M = st_matrix("M")
lambda = J(cols(M), 4, .)
for(t=1; t<=cols(M); t++) {
mt = invvech(M[., t])
lambda[t, .] = symeigenvalues(mt)
}
lambda
end

The output shows:

invvech():  3498  invalid vech
<istmt>:     -  function returned error
----------------------------------------------------------------------------
--------------------------------
r(3498);

.
. lambda
unrecognized command:  lambda
r(199);

.
. end
unrecognized command:  end
r(199);

if I type:
mata:
M = st_matrix("M")
lambda = J(cols(M), 4, .)
for(t=1; t<=cols(M); t++) {
mt = invvech(M[., t])
lambda[t, .] = symeigenvalues(mt)
}

the output shows:

invvech():  3498  invalid vech
<istmt>:     -  function returned error
----------------------------------------------------------------------------
--------------------------------
r(3498);

Do you know where's the error of my codes?

Thanks!

Jingjing Li
University of Toronto

*
*   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/

```
```

*
*   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/
```