[R] Generating uniformly distributed correlated data.

Søren Faurby soren.faurby at biology.au.dk
Sun Feb 20 03:17:42 CET 2011


I wish to generate a vector of uniformly distributed data with a  
defined correlation to another vector

The only function I have been able to find doing something similar is  
corgen from the library ecodist.

The following code generates data with the desired correlation to the  
vector x but the resulting vector y is normal and not uniform  
distributed

library(ecodist)
x <- runif(10^5)
y <- corgen(x=x, r=.5)$y

Do anyone know a similar function generating uniform distributed data  
or a way of transforming y to the desired distribution while keeping  
the correlation between x and y

Kind regards, Soren



More information about the R-help mailing list