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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Putting a multivariate normal draw into a matrix?


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Putting a multivariate normal draw into a matrix?
Date   Tue, 7 May 2013 09:29:01 +0200

On Tue, May 7, 2013 at 8:33 AM, Nick Chandler-Klein wrote:
> I'm trying to make a draw from a non-orthogonal multivariate normal
> distribution and use that draw as starting values for a ml routine,
> which means I need the draw to be in matrix form. Is there a way to do
> this?

What about this:

*------------------ begin example ------------------
mata:

V = 1, .2 \ .2, 1

A = cholesky(V)
draw= rnormal(10000,2,0,1)
draw = (A*draw')'

end

*------------------- end example -------------------
* (For more on examples I sent to the Statalist see:
* http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index