you probably want to use mvrnorm() from package MASS, e.g., library(MASS) mu <- c(-3, 0, 3) Sigma <- rbind(c(5,3,2), c(3,4,1), c(2,1,3)) x <- mvrnorm(1000, mu, Sigma, empirical = TRUE)
colMeans(x) var(x) I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Rauf Ahmad" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Tuesday, February 13, 2007 3:14 PM Subject: [R] Generating MVN Data > Dear All > > I want to generate multivariate normal data in R for a given > covariance > matrix, i.e. my generated data must have the given covariance > matrix. I > know the rmvnorm command is to be used but may be I am failing to > properly assign the covariance matrix. > > Any help will be greatly appreciated > > thanks. > > M. R. Ahmad > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
