Bookmark and Share

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

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

st: use mata loop to generate matrix

From   Zhi Su <>
To   statalist <>
Subject   st: use mata loop to generate matrix
Date   Fri, 20 May 2011 16:02:40 -0400

I want to construct a simulated Y mean matrix that is a 667x4 matrix.
XB is drawn from a dataset with 667 observations and four variables
"xbm1", "xbm2", "xbm3","xbm4" . U is drawn from 4 normal distribution
with a variance-covariance V.The draw is repeated 1000 times.  Here is
what I do

/*number of repetions*/

/*Multiple draws from multivariate normal distribution with variance
and covariance V */

for(k=1;k<=667;k++) {

XB=st_data(k,("xbm1", "xbm2", "xbm3","xbm4"))



I can get means of each simulated Y by looping the process from 1 to
667.  But I do not know how to put the mean row vectors into a 667X 4
Anyone can give me some suggestions?
Zhi Su
348 Holmes Hall
Northeastern University
360 Huntington Avenue
Boston, MA 02115
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index