[R] How to simulate correlated data

Kristel Joossens kristel.joossens at econ.kuleuven.be
Thu Dec 15 16:56:08 CET 2005


So what you actually wnat is a multivariate normal distribution!
with mean c(20,40) and covariance matrix 
cbind(c(5,0.6*sqrt(5,10)),c(0.6*sqrt(5,10),10))
[Since Corr(x,y) = Cov(x,y)/sqrt(Var(x)*Var(y))


Look at the mvtnorm package, for function rmvnorm


Trying RSiteSearch("Multivariate normal distribution")
should also bring you to the package

Best regrads,
Kristel



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

-- 
__________________________________________
Kristel Joossens        Ph.D. Student
Research Center ORSTAT  K.U. Leuven
Naamsestraat 69         Tel: +32 16 326929
3000 Leuven, Belgium    Fax: +32 16 326732
E-mail:  Kristel.Joossens at econ.kuleuven.be
http://www.econ.kuleuven.be/public/ndbae49

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm




More information about the R-help mailing list