If you are comfortable with a matrix language than you should look at
Mata, see -help mata-.
Hope this helps,
Maarten
--- Paulo Regis <[email protected]> wrote:
> Hello all,
>
> I am having some problems creating weighted average variables. I
> usually work with gauss and I would use matrix operations to do this.
> In Stata, a similar procedure may be
>
> mkmat x1-x5, mat(XMAT)
> mkmat m1-m10, mat(MMAT)
> mat WXMAT = MMAT*XMAT
> svmat WXMAT, names(mx)
>
> In this example, you have five variables (x1-x5) with 10 observations
> (_N=10) and ten variables (m1-m10) that are the weights. You end up
> with five new variables (mx1-mx5) which are the weigthed average of
> the original x variables. Alternatively, I have tried to use the
> command egen (using the function total()), following this old tread
>
> http://www.stata.com/statalist/archive/2002-08/msg00458.html
>
> I modified the file "_gmean.ado" to introduce a weighting variable.
> Working out the code, you can obtain mx1-mx5, however, you have to
> modify the code for each variable.
>
> The problem of the first alternative is that it takes a lot of time.
> This may become especially problematic if the number of observation
> is
> large enough while the second alternative is not a "general" solution
> (also, there are some efficiency problems since it creates several
> unnecessary variables). There is any other alternative to do this?
>
> Thank you,
>
> Paulo
> *
> * 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/
>
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
__________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
* 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/