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   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: use Mata to calculate the eigenvalues of the matrix
Date   Sun, 8 Mar 2009 19:06:12 -0000

The code you show won't work, so it does not explain much. But your
regions X years set-up should be irrelevant. But show us the matrix: 

. mat li M 

Nick 
[email protected] 

[email protected]

Thank you martin and Nick!

My matrix M can be 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:

generate 11=...
generate 21=...
...
generate 44=...
mkmat h*, mat (M)

Then the mata codes I mentioned in previous posting.

But the 126 obervations are composed of 7 regions, 18 years  
(7*18=126). Does it cause the
problem?

Quoting Nick Cox <[email protected]>:

> Mata never even tries to calculate any eigenvalues, as before that
point
> -invvech()- chokes on what you feed it.
>
> To hear more, you need to tell us more about your matrix M.
>
> As Martin said, -moremata- is not invoked here and so appears
irrelevant
> to your problem.
>
> Nick
> [email protected]
>
> [email protected]
>
> 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?

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index