[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Hau Chyi" <hauchyi@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: element wise division of matrices |

Date |
Wed, 30 Jul 2008 18:19:20 -0500 |

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 <jnvictor@pitt.edu> 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: jnvictor@pitt.edu > 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/

**References**:**st: element wise division of matrices***From:*"Victor, Jennifer Nicoll" <jnvictor@pitt.edu>

- Prev by Date:
**Re: st: List command** - Next by Date:
**Re: st: question with MLE and complex model** - Previous by thread:
**st: RE: element wise division of matrices** - Next by thread:
**st: Harounan Kazianga is out of the office.** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |