Re: [R] Simulate data based on correlation coefficient
Similar questions have been asked here before. See http://finzi.psych.upenn.edu/R/Rhelp02a/archive/110042.html for one possible answer (your case will be simpler than this). -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 >
Re: [R] Simulate data based on correlation coefficient
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"