Statalist


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

st: AW: cross products in mata


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: cross products in mata
Date   Mon, 6 Jul 2009 14:33:43 +0200

<> 



*************
help mf_cross
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Edwin Leuven
Gesendet: Montag, 6. Juli 2009 14:31
An: [email protected]
Betreff: st: cross products in mata

hello,

i have a view X on k variables and a (k x k) matrix W

i need a vector where row i equals X[i,.]*W*X[i,.]'

at the moment i do the following

xwx = J(st_nobs(), 1, .)
for (i=1; i<=st_nobs(); ++i) 
    xwx[i] = X[i,.]*W*X[i,.]'

which does the trick, but i was wondering whether it is possible to speed
this up?

thanks in advance for your suggestions.

regards, edwin
*
*   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/


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index