[R] How to simulate correlated data
Robin Hankin
r.hankin at noc.soton.ac.uk
Thu Dec 15 16:50:10 CET 2005
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 at 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
More information about the R-help
mailing list