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

From |
"Paulo Regis" <pauloregis.ar@googlemail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: matrices and linear transformations |

Date |
Wed, 4 Jun 2008 17:17:05 +0100 |

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/

**Follow-Ups**:**Re: st: matrices and linear transformations***From:*Maarten buis <maartenbuis@yahoo.co.uk>

- Prev by Date:
**Re: st: Problem with xtmixed** - Next by Date:
**Re: st: string_functions "Titlecase"?** - Previous by thread:
**st: string_functions "Titlecase"?** - Next by thread:
**Re: st: matrices and linear transformations** - Index(es):

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