Statalist


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

st: RE: How to do a basic task in MATA that I cannot explain in English


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: How to do a basic task in MATA that I cannot explain in English
Date   Mon, 5 Jan 2009 18:31:50 -0000

In addition to other comments: 

The flavour of this example appears to be that you won't need all the
matrices at once. If that is so, the question can be avoided by working
with one matrix at a time. 

Nick 
[email protected] 

Tiago V. Pereira

Although I know how to create basic Stata commands, I have no idea how
to
express some tasks what I am trying to do in technical terms (in
English).
Hence, I believe that showing one example will be the most
straightforward
manner to make myself clear.

I have just started to play with some Mata lines, and would like to know
if it is possible to add something that does the same role of `i' in
Stata
programming.

For example:

forvalues i = 1/100 {
matrix TEST_`i' = (`i',43,500)
}


will create 100 vectors/matrices: TEST_1..TEST_100

Taking the simple lines below, is it possible to create matrices TEST_1
to
TEST_100 too?


*/-----------------START--------------

clear
set obs 100
gene MATA = round(uniform()*45)
gene RULES = round(uniform()*15)
mata
X = st_data(.,("MATA", "RULES"))
Y = st_data(.,("RULES", "MATA"))
for (i=1; i<=100; i++) {
TEST = X[i,1]\Y[i,1]\X[i,1]\Y[i,1]
}
end
*/-----------------END-----------------


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