Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Big set of 1x1 matrices into scalar - how to do fast?


From   "Schnepf S.V." <S.V.Schnepf@soton.ac.uk>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: Big set of 1x1 matrices into scalar - how to do fast?
Date   Fri, 19 Jun 2009 17:31:57 +0100

Dear Statalist users,

        forvalues i = 1(1)3641 {
        mat c`i'= b*Xi`i''
        capture drop c
        quietly gen c= el(c`i',1,1)
        quietly sum c
        quietly replace result=r(mean) in `i'
        drop c
        }

For a large set of individuals (here 3641), I have to multiply two vectors, with b and Xi`I' being a 1x10 vector. As a result I receive for each individual a 1x1 matrix, just containing 1 value.
I now would like to produce one single scalar variable, that for each `I' row contains the number of c`I'.

I have found a way how to do that, given above. But my simple solution is incredibly slow.

Could you help?
Many thanks
Sylke V. Schnepf

Ps. Many thanks for the help on the program for programming a weighted regression, very helpful.



*
*   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/



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