Possible Duplicate:
How to generate correlated random numbers (given means, variances and degree of correlation)?
I have been trying to generate two random variables with correlation of -0.9 but have not been successful. I have tried:
x1 <- rnorm(200, mean=0, sd=1)
x2 <- rnorm(200, mean=0, sd=1)
z <- -0.9*x1+sqrt((1-(-0.9)))*x2
cor(x1,z)
But it did not work.
I tried also the ?mvrnorm function, but it did not work either. How I can get this done??