Thanks to everybody for helpfull answers.

In case other people want to generate similar data at one time
The one function I have found without any apparant bias ( such as extreme clustering of the datapoints along one or both diagonals in plot(x,y) or a slight bias in the generated correlations is the function pcu from the library simecol

Kind regards, Soren

Citat af Spencer Graves <spencer.gra...@structuremonitoring.com>:

You may also be interested in the "psych" package or possibly "mvtBinaryEP". I found these using "sos":


library(sos)
tc <- findFn('tetrachoric correlation') # 26 matches
tcs <- findFn('tetrachoric correlations')#27 matches
tc. <- tc|tcs
summary(tc.) # 35 links in 5 pkgs
tc.


All but 3 of the 35 links are to "psych", and 2 of the remaining 3 are to two different copies of "mvtBinaryEP". You might also Google for "tetrachoric correlation".


# OR:
u <- findFn('uniformly distributed correlated data') # 3 matches


      Hope this helps.
      Spencer


On 2/19/2011 9:21 PM, Jorge Ivan Velez wrote:
Hi Soren,

Take a look at http://tolstoy.newcastle.edu.au/R/help/05/07/7741.html

HTH,
Jorge


On Sat, Feb 19, 2011 at 9:17 PM, Søren Faurby<>  wrote:

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

______________________________________________
R-help@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.

        [[alternative HTML version deleted]]



______________________________________________
R-help@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.


______________________________________________
R-help@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.

Reply via email to