Mollet, Fabian
2007-Mar-23 14:36 UTC
[R] simulate from a multivariate lognormal distribution with fixed covariance/correlation structure
Dear R users I use simulated data to evaluate a model by sampling the parameters in my model from lognormal distributions. I would like these (lognormal distributed) parameters to be correlated, that is, I would like to have pairwise samples of 2 parameters with a given correlation coefficient. I have seen that a covariance matrix can be fixed when generating random variables from a multivariate normal distribution e.g. by the function mvrnorm. Is there a function to do the same (as illustrated below from a multivariate normal) from a multivariate lognormal distribution? Thank you! Fabian library(MASS) corab<-0.8 a.mu<-2; a.sd<-1 b.mu<-1; b.sd<-0.5 sigma<-matrix(c(a.sd^2,corab*a.sd*b.sd,corab*a.sd*b.sd,b.sd^2),nrow=2,nc ol=2,byrow=T) mvn<-mvrnorm(n = 1000, mu=c(a.mu,b.mu), Sigma=sigma, tol = 1e-6, empirical = TRUE) avar<-mvn[,1] bvar<-mvn[,2] cor(avar,bvar) [[alternative HTML version deleted]]