Andras,
I am no expert but you could start with correlated normal random variables
and then convert to lognormal.
You can use rmvsnorm from the {fCopulae} package to generate the correlated
normals.
Here is a call that I have used in the past:
set.seed(12345)
numSims<-10 # number of multivariate simulations
nVars<-3 # number of variables per simulation
sd<-.3 # Standard deviation
corrMatrix<-matrix(c(1,.2, .1, .2, 1, .2, .1, .2, 1), nrow = 3) #
Correlation matrix
sims<-rmvsnorm(numSims, dim=nVars, Omega=corrMatrix*sd^2)
sims
1 2 3
1 0.17565865 0.000961992 0.23987213
2 0.21283981 0.576746426 0.54851754
3 -0.03279099 0.102383699 -0.17187533
4 -0.13604915 0.125701955 -0.44056873
5 0.18176624 -0.184257203 -0.49189846
6 -0.54538679 0.131041175 0.52003437
7 0.18902957 -0.222728926 -0.17124538
8 -0.08285523 -0.114034555 0.15543724
9 -0.08524792 0.312371313 0.23281669
10 -0.27579660 0.032647156 -0.05873216
attr(,"parameters")
attr(,"parameters")$xi
[1] 0 0 0
attr(,"parameters")$Omega
[,1] [,2] [,3]
[1,] 0.090 0.018 0.009
[2,] 0.018 0.090 0.018
[3,] 0.009 0.018 0.090
attr(,"parameters")$alpha
[1] 0 0 0
Note that in my example above the mean is 0 but can be changed using the "mu"
parameter. See the docs for fCopulae.
This should help you convert the normal random variables to lognormal:
http://en.wikipedia.org/wiki/Log-normal_distribution
Good luck,
KW
> Dear All,
>
> wondering if someine can access the link to the randsamp code referenced in
> the R-help archive here:
> http://www.mail-archive.com/[email protected]/msg75645.html ? I have
> tried but for whatever reason I can not get trough. My problem seems to be
> similar to what the author originally described there, so having access to it
> would be great. Else, if you have any thougths on sampling from a
> distribution assumed to be log-normal with expected means + SD of
>
> a=5.04 + 0.56
> b=1.89 + 0.19
> c=0.43 + 0.08
> d=0.44 + 0.07
>
> and covariance matrix of:
>
> a b c d
> a 0.31
> b 0.015 0.04
> c -0.019 0.000007 0.0064
> d 0.0069 -0.0069 -0.000067 0.0048
>
> would be greatly appreciated. Can this be done with a function?I been working
> on this for months now but can not crack it. I can not find a package that
> has a function to deal with this. thanks,
>
> Andras
--
______________________________________________
[email protected] 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.