On Sat, Apr 30, 2011 at 11:39:43PM -0400, Chee Chen wrote: > Dear All, > For function: rmvnorm{mvtnorm} in (library mvtnorm, not splus2R), if I > generate 2 bivariate normal samples as follows: > > rmvnorm(2,mean=rep(0,2),sigma=diag(2)) > [,1] [,2] > [1,] 2.0749459 1.4932752 > [2,] -0.9886333 0.3832266 > > Where is the first sample, it is stored in the first row or the first column? > Does this function store samples row-wise or column-wise?
Hi. The call rmvnorm(3,mean=rep(0,2),sigma=diag(2)) produces [,1] [,2] [1,] 2.5795462 0.7862570 [2,] 0.2630356 0.3879757 [3,] -0.5035942 0.5804228 which shows that the samples are rows. The arrangement that rows are the vectors of observations and columns are variables is typical in R. The examples in ?rmvnorm demonstrate this, since the mean is computed using colMeans() and variance using var(). See also ?var. Hope this helps. Petr Savicky. ______________________________________________ R-help@r-project.org 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.