[R] Correlated Multivariate Distribution Generator

Enrico Schumann
Wed, 27 Jul 2011 07:24:17 -0000

Hi Yue Yu,

similar questions have been discussed several times on this list; you may
want to search the archives.

Do you mean linear correlation, or rank correlation? In general, a given
linear correlation will not always be attainable (though in your case, it
probably will). If _rank_ correlation is fine, you could do something like
this:

(1) create Gaussians X with a given linear correlation (which is almost
identical to rank correlation in the Gaussian case, but you can even correct
this*)

(2) put X into the distribution function of the normal: you get uniforms U.
Since the distribution function is monotone, the rank correlation will
remain unaltered. Hence the U are (rank-)correlated just as the X.

(3) put U into the inverse of the desired distribution function. The inverse
is mononote as well, so the rank correlation remains the same.

[This approach will only be practical if you can compute the inverse
reasonably fast.]


Regards,
Enrico

* see, eg, http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1681917


> -----Urspr?ngliche Nachricht-----
> Von: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] Im Auftrag von Yue Yu
> Gesendet: Mittwoch, 27. Juli 2011 05:01
> An: r-help at r-project.org
> Betreff: [R] Correlated Multivariate Distribution Generator
>
> Dear R User,
>
> I am wondering if there is a way to generate correlated
> multivariate non-normal distribution?
>
> For example, I want to generate four correlated negative
> binomial series with parameters r=10, p=0.2, based on the
> correlation coefficient matrix
> |   1   0.9  0.8  0.8 |
> | 0.9     1  0.8  0.8 |
> | 0.8  0.8     1  0.9 |
> | 0.8  0.8  0.9     1 |
>
> Thank a lot.
>
> Best,
>
> Yue Yu
>
> ______________________________________________
> R-help at r-project.org 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.