Re: [R] How to simulate correlated data

From: Robin Hankin <r.hankin_at_noc.soton.ac.uk>
Date: Fri 16 Dec 2005 - 02:50:10 EST

Hi

you need

library(mvtnorm)

then

a <- rmvnorm(n=10000,mean=c(20,40),sigma=matrix(c(5,0.6*sqrt(50), 0.6*sqrt(50),10),2,2))

will do what you want

HTH rksh

On 15 Dec 2005, at 15:33, Lisa Wang wrote:

> Hello there,
>
> I would like to simulate X --Normal (20, 5)
> Y-- Normal (40, 10)
>
> and the correlation between X and Y is 0.6. How do I do it in R?
>
> Thank you very much
>
> Lisa Wang Msc.
> Princess Margaret Hospital
> Toronto, Ca
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-
> guide.html

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri Dec 16 03:06:26 2005

This archive was generated by hypermail 2.1.8 : Fri 16 Dec 2005 - 04:29:52 EST