Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: AW: Matrices utilities, Basic calculations. When to start using Mata over Stata? |

Date |
Fri, 23 Apr 2010 14:09:43 +0200 |

<> Re loops in -mata-, try Kit`s http://www.stata.com/meeting/fnasug08/baum_StataMata.beamer.FNASUG08.pdf, slide 17-18. HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Radaf paf Gesendet: Freitag, 23. April 2010 13:50 An: statalist@hsphsun2.harvard.edu Betreff: st: Matrices utilities, Basic calculations. When to start using Mata over Stata? Hi all, I have a total of 20 matrices, A1-A10 and B1-B10 of size 25x36 I am trying to do the sum of each row of the matrix A and compare them with the sum of each row of the matrix B. Then I retain the highest sum and put it in a new matrix, say C. The "rowsum" utility in Mata is appealing, but I couldn't figure out how to create the loops ( no "foreach" command?), generate new matrixes names automatically (for the matrices C) and access my 20 matrices within the loops in Mata. Here is what I would do if I could use "rowsum" in Stata: foreach n in 1 2 3 4 5 6 7 8 9 10 {; matrix c'n´= J(rowsof(A'n´),1,0) *I create my matrix c (vector of 25 rows) containing only 0 values ; foreach i in 1-25 {; * where i correspond to the number of rows; R_sum_A'n´=rowsum(A'n´) ; R_sum_B'n´=rowsum(B'n´) ; *I compare the two sums and if the rowsum of A is bigger than B I put it in the new matric C, if not I leave it equals to 0 ; if el(R_sum_A'n´,'i´,1)> el(R_sum_B'n´,'i´,1) matrix C'n´['i´,1] =el(R_sum_A'n´,'i´,1) ; }; }; But I cannot use "rowsum" into stata . So what would you suggest ? Thanks a lot Raphael _________________________________________________________________ Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. https://signup.live.com/signup.aspx?id=60969 * * 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/ * * 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/

**References**:**st: Matrices utilities, Basic calculations. When to start using Mata over Stata?***From:*Radaf paf <ladwen@hotmail.com>

- Prev by Date:
**st: RE: Matrices utilities, Basic calculations. When to start using Mata over Stata?** - Next by Date:
**Re: st: calculate probability for clogit** - Previous by thread:
**st: RE: Matrices utilities, Basic calculations. When to start using Mata over Stata?** - Next by thread:
**st: Re: st: Matrices utilities, Basic calculations. When to start using Mata over Stata?** - Index(es):