Hi Logan,
In Ox the implementation of the solution provided by Richard is even simpler. The function rann(r,c) generates random numbers from a standard normal distribution. For your application r (number of rows) will be the dimension of your multivariate distribution, and c (number of colums) the number of drawings you want. E.g.
x = rann(5,1000);
Decompose the variance/covariance matrix using the function choleski(A).
P = choleski(varcov);
Premultiply the vector of random numbers to get numbers with the multivariate normal distribution.
z = P * x;
Covariance: E Pxx'P'= PP' = varcov, as desired.
Finally, take exp to get the lognormal distributed numbers;
y = exp(x);
I am not sure whether this is what you want. The covariance matrix of the resulting multivariate lognormal distribution is not equal to the varcov-matrix used in the algorithm. The varcov-matrix used in the algorithm is the covariance matrix after taking logs of the lognormally distributed variables. May be this is what you intend. Otherwise you will need an additional transformation which might be statistically complicated.
Regards,
Jaap
-----------------------------------------------------------------
Jacob J. de Vries
Department of Spatial Economics
Vrije Universiteit
De Boelelaan 1105
NL 1081 HV Amsterdam
Phone +31 20 59 86142
Fax +31 20 59 86004
[log in to unmask]
http://staff.feweb.vu.nl/jjvries/
-----------------------------------------------------------------
---------
From: The ox-users list is aimed at all Ox users [mailto:[log in to unmask]] On Behalf Of Dr RJF Hudson
Sent: woensdag 15 juli 2009 11:40
To: [log in to unmask]
Subject: Re: Generating random numbers for a multivariate log-normal distribution
Dead simple..
y = e^x
where x is a sample from a normal distribution.
y is a sample from a lognormal variable....
generate 1000 (say) ND numbers using the algorithm on page 113 from Cooke and Cravens Basic Stastical Computing
using chosen variance and mean.
put the numbers in the vector (say) x(t) where x(t) is of dimension (1000)
then make a vector y(t) (say) that will hold 1000 numbers.
then
for i= 1 to 1000
let y(i)= 2.7182818^x(i)
next
then y(i) contains the 1000 samples from a lognormal variable..
etc etc....
use F95 or simpler still use GWBasic...
Hope this helps..
Richard Hudson
DR RJF Hudson Qld Australia
[log in to unmask]
----- Original Message -----
From: Logan Kelly
To: [log in to unmask]
Sent: Tuesday, July 14, 2009 10:31 PM
Subject: Generating random numbers for a multivariate log-normal distribution
I am looking for a way to generate random numbers from a multivariate log-normal distribution with a given variance / covariance matrix.
Logan Kelly, Ph.D.
Bryant University ~ Department of Economics
1150 Douglas Pike ~ Smithfield, RI 02917
Office: (401) 232-6897 ~ Fax: (401) 232-6319
------------------------------------------------------------
View my research on my IDEAS Author page:
http://ideas.repec.org/e/pke111.html
And on my SSRN Author page:
http://ssrn.com/author=868256
------------------------------------------------------------
|