Statalist


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

st: need mata or perhaps egen help


From   "David Merriman" <dmerrim@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: need mata or perhaps egen help
Date   Thu, 22 May 2008 15:06:12 -0500

I have a set of 584 communities and a square (584x584) matrix D that
measures the
distance from each community to each community.

For each community I also have (584x1) vector (EDI) containing a
variable that measures (essentially) the total amount spent on
economic development incentives.

I have this data for a number of years but I do not think that is
important to my programming issues.

For each of my communities I want a single variable that measures the
total amount spent within a given distance (say 15 miles) on economic
development incentives.

I can convert my D matrix into a zero/1 matrix
(assign zero to home community and and any community more than 15
miles distant, 1 otherwise) and Call  this DT

Seems I should be then be able to use mata to do the matrix multiplication

R=DT*EDI

R should be a 584x1 vector with the variable I need.


The problem (I think) is that I have never used mata and am having a
hard time figuring out how to feed my stata data into mata, do the
multiplication and get the result back  to stata.

Can anyone tell me how to do this?
Maybe there is an easier way to do it with egen or some other stata commands.

Thanks
Dave Merriman




-- 
David Merriman
dmerrim@gmail.com
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index