Re: [R] How to simulate correlated data

From: Kristel Joossens <kristel.joossens_at_econ.kuleuven.be>
Date: Fri 16 Dec 2005 - 02:56:08 EST

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@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@econ.kuleuven.be
http://www.econ.kuleuven.be/public/ndbae49

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

______________________________________________
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:22:05 2005

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