Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: triangular matrices


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: Re: triangular matrices
Date   Sat, 18 Nov 2006 09:06:29 -0500

Elementary, my dear Brendan. No need to do anything in the Stata matrix language in order to get the Stata variable into Mata. If you want to do anything with matrices, you should pick up some familiarity with Mata; it makes life a lot simpler.

clear
input v1 v2 v3
1 1 0
1 2 12
1 3 13
1 4 14
2 2 0
2 3 23
2 4 24
3 3 0
3 4 34
4 4 0
end
mata:
st_view(a=., ., "v3")
st_matrix("b",invvech(a))
end
mat list b



Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


On Nov 18, 2006, at 2:33 AM, Brendan wrote:


Thanks for that solution -- it points me towards Mata which I had
been studiously ignoring.

Unfortunately, if I understand things correctly, this introduces a
size limitation: for an m*m dissimilarity matrix, the "mkmat
v3,mat(a)" statement will create an m*(m-1)/2 vector. If I want m
to run up close to the "set matsize" limit, this is not possible.
(My understanding might be wrong: if I say "set matsize 100" I can
create 100*100 matrices but not 101*1 vectors?).
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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