Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Gordon Hughes <G.A.Hughes@ed.ac.uk> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: Mata - generalised cross products of the form X'SX |
Date | Tue, 08 Feb 2011 12:12:59 +0000 |
This is a standard form in any GLS type calculation. They are not directly amenable to use with the Mata function --cross()-- but they could be got into that form by forming by factorising S=QQ', then forming P=Q'X, and finally using P=cross(P,P).
Two questions follow:A. Is there any Mata function that does this more directly? Maybe Stata Corp might consider extending --cross()-- to handle such cases. The command --matrix glsaccum-- does this in Stata.
B. Roughly, under what conditions might this sequence of steps reduce execution time and/or memory use on the assumption that the dimension of S is large relative to cols(X)? In a related context I have to calculate X'B'BX where B is square but not symmetric and found that use of --cross()-- does not save much (if any) time, though it is probably more efficient on memory. Hence, the overhead of factorisation may not pay off. On the other hand, the initial factorisation would only need to be done once per function call, whereas the steps involving X have to be performed thousands of times per function call.
Gordon Hughes g.a.hughes@ed.ac.uk * * 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/