To the all-knowing, the signal that you were working with 126 rows
should have been enough information.
Look again at the help for -invvech()-:
"invvech(v):
v: (n*(n+1)/2) x 1
result: n x n
invvech(v) aborts with error if v does not have 0, 1, 3, 6, 10, ...
rows."
126 rows does not match the form n(n+1)/2 needed to get a square matrix
out of -invvech()-. 120 rows or 136 rows would work, but not 126.
Nick
[email protected]
[email protected]
M[126,16]
halflnpllnpl halflnpklnpk halflnpmlnpm halflnpelnpe halflnqlnq
halftt h11
r1 55.698589 3.6893287 7.4771399 18.149426
50.228111 .5 -.08101387
r2 55.925751 4.2461691 7.5901814 17.818066
50.520424 2 -.07783842
r3 55.890606 5.0145068 8.2533903 17.348637
49.332706 4.5 -.06268991
r4 55.84235 6.8188863 8.1996651 17.327908
48.37619 8 -.04702383
r5 55.992165 11.663833 8.5312452 17.296404
48.428661 12.5 -.04062275
r6 56.231369 6.2716689 9.8907461 17.231161
47.613789 18 -.02769819
..................................................................omitte
d
r125 59.936024 6.0803957 8.1817226 11.001316
48.745419 144.5 -.10420492
r126 62.886497 5.7553158 8.4018955 11.243708
47.780876 162 -.11177195
h21 h31 h41 h22 h32 h42 h33
r1 .0058905 .04511028 .02139651 -.03382511
.03340751 -.0086062 -.10248575
r2 .00514857 .05326439 .02111828 -.03219827
.03637264 -.00870738 -.07974763
....................................................................omit
ted
r126 .01168905 .07623301 .02273416 -.0396621
.03610333 -.00847654 -.10935289
h43 h44
r1 -.00469169 -.0092736
r2 -.00357977 -.0086003
....................................................................omit
ted
r126 -.00577275 -.0086003
Quoting Nick Cox <[email protected]>:
> 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/