Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

re: st: matrix operations when N exceeds matsize


From   Kit Baum <[email protected]>
To   [email protected]
Subject   re: st: matrix operations when N exceeds matsize
Date   Tue, 18 May 2010 16:35:48 -0400

<>
Re my last posting, to move Stata variables into Mata and get the resulting matrix back is straightforward (even with N = 120,000):

clear
set obs 120000
forv i=1/10 {
	g W`i' = runiform()
	g B`i' = runiform()
	loc wl "`wl' W`i'"
	loc bl "`bl' B`i'"
}
mata
st_view(W=., ., st_local("wl"))
st_view(B=., ., st_local("bl"))
vard = runiform(10,10)
result = W' * B * vard * B' * W
st_matrix("result", result)
end
mat list result

NB. I have about 500m allocated to Stata (which would work even on a 32-bit machine). The use of views in Mata avoids making a copy of those 120000 x 10 x 2 variables, which saves a great deal of memory.

Kit Baum   |   Boston College Economics & 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index