Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

re: st: matrix operations when N exceeds matsize


From   Christopher Baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   re: st: matrix operations when N exceeds matsize
Date   Tue, 18 May 2010 14:04:15 -0400

<>
I need to calculate the following quadratic form:  W' *M* W where W is
NxK and M is K x K
However M is the result of the following quadratic form B*VARD*B'  where
B is N x K and VARD is a K x K.   My N exceeds the 11,000 limit and so I
have been trying to figure out how to use accum, glsaccum and opaccum to
be able to calculate the above equations.

I presume that M is NxN, not KxK, for conformability.  As Martin says, this is no big deal for Mata.

. mata

: W=runiform(12000,10)

: B=runiform(12000,10)

: vard = runiform(10,10)

: result = W' * B * vard * B' * W

: result
                  1             2             3             4             5             6             7             8
     +-----------------------------------------------------------------------------------------------------------------
   1 |  500400126.7   502295081.4   504071894.6   506490624.3   503828841.1     504360796   502899956.9   502335048.8
   2 |  502520308.9   504423889.9   506207652.2   508637078.7   505964282.9   506498530.5     505031154   504464184.8
   3 |  503961410.3     505869513   507659337.5   510095053.5     507413961   507949984.2   506478567.9   505909741.6
   4 |  506552723.5   508470854.6     510269677   512718202.6   510023719.3   510562029.6     509083469   508511536.3
   5 |  503944502.8   505852248.3   507642701.4   510077963.4   507397387.9     507932971   506462068.8   505892912.3
   6 |    504252263   506161836.8     507952473   510389659.2   507707813.6   508244061.9   506771261.4   506202335.2
   7 |  502875242.1   504779017.9   506565459.6   508995767.4     506320617   506855019.3   505387477.6   504819526.7
   8 |  502543459.1   504446358.7     506231060   508660125.2   505987241.3   506521087.1   505054315.5   504486785.1
   9 |  506804665.2   508723669.8   510523745.9   512973124.8   510277507.7   510816307.7   509336482.3   508764468.2
  10 |  498583726.2   500471466.8   502242467.3   504652111.6   502000288.9   502529989.8   501074705.3   500511723.8
     +-----------------------------------------------------------------------------------------------------------------
                  9            10
      -----------------------------+
   1      506612046   498613766.3  |
   2    508759658.4   500727276.5  |
   3    510216844.6   502161667.3  |
   4    512841038.5   504744482.2  |
   5    510200215.9   502144830.7  |
   6    510512613.1   502452342.9  |
   7    509117498.9   501079549.6  |
   8    508782174.3     500749475  |
   9    513096412.7   504995151.8  |
  10      504773350   496803681.4  |
      -----------------------------+


Kit Baum   |   Boston College Economics and DIW Berlin   |   http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming   |   http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata   |   http://www.stata-press.com/books/imeus.html


*
*   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   |   Site index