Dear all R users, Please forgive me if my question is too trivial. Suppose I have two variables, (x,y) which is log-normally distributed with expected value (mu1, mu2) and some variance-covariance matrix. Now I want to draw a random sample of size 1000 from this distribution. Is there any function available to do this? Thanks and regards, Megh
?rlnorm On 11/18/06, Megh Dal <megh700004@yahoo.com> wrote:> > Dear all R users, > > Please forgive me if my question is too trivial. > Suppose I have two variables, (x,y) which is > log-normally distributed with expected value (mu1, > mu2) and some variance-covariance matrix. Now I want > to draw a random sample of size 1000 from this > distribution. Is there any function available to do > this? > > Thanks and regards, > Megh > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]
On 18-Nov-06 Megh Dal wrote:> Dear all R users, > > Please forgive me if my question is too trivial. > Suppose I have two variables, (x,y) which is > log-normally distributed with expected value (mu1, > mu2) and some variance-covariance matrix. Now I want > to draw a random sample of size 1000 from this > distribution. Is there any function available to do > this? > > Thanks and regards, > MeghBrowsing around, I have found R code listed at http://www.internal.eawag.ch/~reichert/sysanal.r This lists several functions. One is 'randsamp' which can generate a random sample from either a normal or a lognormal distribution. You may find it useful to extract the "lognormal" part of the code (which seems to be effectively independent of the "normal" part of the code), and adapt it to suit your purposes. Caveat: I have not tried this code, but it looks as though it does it correctly -- i.e. you specify the vector of means of the components of the lognormal random vector, the vector of their standard deviations, and the matrix of their correlations (easily derivable from the matrix of their covariances using the SDs), and you get a result with n rows, each row being a sample from the MV lognormal with specified means and covariances. (You can omit the line which calculates the density function using another function 'calc.pdf'). NB: The source should be acknowledged! Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 18-Nov-06 Time: 17:12:21 ------------------------------ XFMail ------------------------------
> Dear all R users, > > Please forgive me if my question is too trivial. > Suppose I have two variables, (x,y) which is > log-normally distributed with expected value (mu1, > mu2) and some variance-covariance matrix. Now I want > to draw a random sample of size 1000 from this > distribution. Is there any function available to do > this? > > Thanks and regards, > MeghIf what you really want is a bivariate lognormal, you can generate first a bivariate normal sample (X,Y) with the function rmvnorm in package mvtnorm. Then exp(X,Y) will be multivariate lognormal.