Re: [R] Simulate data based on correlation coefficient

2007-10-08 Thread Greg Snow
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gustavo Sent: Friday, October 05, 2007 8:48 PM To: r-help@r-project.org Subject: [R] Simulate data based on correlation coefficient Hello all, I have a vector with 1000 values and I would like

Re: [R] Simulate data based on correlation coefficient

2007-10-07 Thread joris . dewolf
Try this: rnormcor - function(x,rho) rnorm(1,rho*x,sqrt(1-rho^2)) a - rnorm(1000,0,1) b - sapply(a, rnormcor, rho = 0.7) cor(a,b) Joris Gustavo

[R] Simulate data based on correlation coefficient

2007-10-06 Thread Gustavo
Hello all, I have a vector with 1000 values and I would like to generate other correlated vector, but with different correlation coefficient (for example, r = 0.7). Any ideas how can I do this? Regards, Gustavo.