|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: A Question on Looping
Dear Statalist
Actually, I have already generated four variable A, B, C, and D that
each contains 43 observation, in Stata 8.2. I want to make 43 square
matrix (2 by 2) using each of 43 observation based on each observation
of these variables. Then, I want to calculate the real Eigenvalues of
each matrix and list the 43 matrix and their Eigenvalues. I need to
write a loop to do this job. Actually, I have already written the
following loop using "foreach command" but I am getting the following
error as follows;
foreach i = 1/43 {
2. matrix K[`i'] = (A[`i'], B[`i'] \ C[`i'],D[`i'])
3. matrix symeigen X[`i'] V[`i'] = K[`i']
4. matrix list K[`i'] V[`i']
5. }
invalid syntax
r(198);
end of do-file
r(198);
Also, alternativley, I have written another alternative do file by
"while" loop but it is also subject to error as follows;
1.local i 1
2. while `i' < 43 {
3. matrix K[`i'] = (lpl_m[`i'], lpm_m[`i'] \ le_m[`i'],lk_m[`i'])
4. matrix symeigen X[`i'] V[`i'] = K[`i']
5. matrix list V[`i']
6. local i = `i' + 1
7. }
too many ')' or ']'
r(132);
end of do-file
r(132);
Could you help me out on this matter and say what is wrong with any of
these alternative loops?
Thanks
Asgar Khademvatani
*
* 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/