Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: a question about matrix looping


From   cuiliweibj <[email protected]>
To   [email protected]
Subject   st: a question about matrix looping
Date   Wed, 29 Oct 2003 17:11:26 +0800

dear all,

Here is my data of matrix.

. matrix list a1

a1[1,5]
           p1         p2         p3         p4         p5
c1  2575.8327  500.06787  186.97998   254.6509  1106.3182


. matrix list p

p[5,5]
           p1         p2         p3         p4         p5
r1  .66871315  .08958182  .02526662  .03012322  .18631518
r2  .33131433  .22863834  .08614853  .07708991  .27680892
r3  .13114183  .09663552  .09053405  .20670988  .47497872
r4  .13119115  .07068948  .07335503  .16629378  .55847055
r5          0          0          0          0          0


I want to get a2, a3 ....a10.

. matrix a2=a1*p
. matrix a3=a2*p
.
.
.
. matrix a10=a9*p

to make it easy, I wrote the code, but it doesn't work.

while `i'<=10{
    matrix a`i+1'=a`i'*p
    local i=`i'+1
    }

and at last I want convert the matrix a1 a2 ...a10 to variables.

Thanks.

CUI liwei.
______________________________________

===================================================================
����2003��Ʒȫ�����У���Ʒ�ʣ���ѡ�� (http://ad4.sina.com.cn/shc/zhuiyu_hprefresh.html)

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