[R] how to generate a random correlation matrix with restrictions

Kingsford Jones kingsfordjones at gmail.com
Sat Aug 29 04:10:12 CEST 2009


Ahh -- Mark Leeds just pointed out off-list that it was supposed to be
a correlation matrix.

Perhaps

R <- matrix(runif(10000), ncol=100)
R <- (R * lower.tri(R)) + t(R * lower.tri(R))
diag(R) <- 1

These are of course uniformly distributed positive correlations.

Kingsford


On Fri, Aug 28, 2009 at 7:36 PM, Kingsford
Jones<kingsfordjones at gmail.com> wrote:
>  R <- matrix(runif(10000), ncol=100)
>
> hth,
>
> Kingsford Jones
>
> On Fri, Aug 28, 2009 at 7:26 PM, Ning Ma<pningma at gmail.com> wrote:
>> Hi,
>>
>> How can I generate a random 100x100 correlation matrix, R={r_ij},
>> where about 10% of r_ij are greater than 0.9
>>
>> Thanks in advance.
>>
>> ______________________________________________
>> 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.
>>
>




More information about the R-help mailing list