############################################################### # ## Generating Multivariate Correlated Data par(mfrow=c(2,2)) ### Method I library(mvtnorm) Sigma<-matrix(c(1.0, .60, .60, 1.0),ncol=2) x <- rmvnorm(n=1000, Sigma, mean=c(100,100)) plot(x) cor(x) ### Method II library(MASS) Sigma <- matrix(c(1,.60,.60,1),ncol=2) x.pop<-mvrnorm(n=1000, mu=c(100,100), Sigma) x.emp<-mvrnorm(n=1000, mu=c(100,100), Sigma, empirical=TRUE) plot(x.pop) cor(x.pop) plot(x.emp) cor(x.emp)