Hi Jennifer,
You need -mata: rawsum=st_matrix("rawsum")-.
A collection of mata function. see: -help m5_intro-
Hope this help.
On Wed, Jul 30, 2008 at 2:53 PM, Victor, Jennifer Nicoll
<[email protected]> wrote:
>
> Hello list:
>
> Thanks to Nick for recommending a running sum of matrices for my problem yesterday. I worked like a dream. Now I have a new problem.
>
> I have created two matrices in Stata using the matrix commands. One is called "rawsum," a 438x1010 matrix. The other is "bothvoting," also a 438x1010 matrix.
>
> I need to create matrix agreecount=(rawsum+bothvoting)/2. No problem.
>
> Now I need to create matrix agreerate=agreecount/bothvoting, where each i,j of 'agreecount' is divided by each i,j of 'bothvoting'. I cannot find a command in Stata's matrix commands to do this type of element-wise division.
>
> So, I've moved into Mata. Mata has a simple element-wise division command: X=A:/B.
>
> But, I am a novice Mata-user and I cannot figure out how to get my 438x438 matrix into Mata. So, I've converted it back to a dataset using the 'svmat' command and I'm trying to get the data into Mata using the 'st_view' command. My data has 438 observations and 438 variables. Essentially, I want to use the command:
> st_view(x., ., "agreecount1",..."agreecount438")
>
> ...then do the same with the 'bothvoting' data, then execute the e-w division command.
>
> I've tried using the 'for' command but cannot figure out the successful execution of a loop in Mata because the syntax is different than Stata's.
>
> How can I do this? Or can you provide a more elegant solution?
>
> Thank you.
> ___________________________________________
> Jennifer Nicoll Victor
> Assistant Professor
> Department of Political Science
> University of Pittsburgh
> 4600 Wesley W. Posvar Hall
> (412) 624-7204
> E-mail: [email protected]
> Homepage: http://www.pitt.edu/~jnvictor
>
>
> *
> * 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/
--
Hau Chyi,
Assistant Professor of Economics
The Wang Yanan Institute for Studies in Economics (WISE)
Xiamen University
http://hauchyi.googlepages.com
*
* 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/