rmvnorm | R Documentation |
Generates a vector of random values from an n-dimensional
multivariate normal distribution whose mean is given by the
n-vector mean
and variance by the
n x n symmetric matrix V
. It uses the method described by
Ripley (1987, p.98)
rmvnorm(mean, V, method = 'eigenanalysis')
mean |
The mean vector of the multivariate normal distribution from which the random values are to be generated. |
V |
The variance matrix of the multivariate normal distribution from which the random values are to be generated. |
method |
The method used to decompose the variance matrix in producing a
a matrix to transform the iid standard normal values. The two
methods available are |
The method is:
a) uses either the eigenvalue or Choleski decomposition of the variance matrix,
V
, to form the matrix that transforms an iid vector of values to a
vector with variance V
;
b) generate a vector of length equal to mean
of standard normal values;
c) premultiply the vector of standard normal values by the transpose of the
upper triangular factor and, to the result, add mean
.
A vector
of length n, equal to the length of mean
.
Chris Brien
Ripley, B. D. (1987) Stochastic simulation. Wiley, New York.
fac.ar1mat
, fac.vcmat
,
in package dae, rnorm
, and chol
.
## set up a two-level factor and a three-level factor, both of length 12
A <- factor(rep(1:2, each=6))
B <- factor(rep(1:3, each=2, times=2))
## generate random values from a multivariate normal for which
#the mean is 20 for all variables and
#the variance matrix has random effects for factor A, ar1 pattern for B and
#residual random variation
mean <- rep(20, 12)
V <- fac.vcmat(A, 5) + fac.ar1mat(B, 0.6) + 2*mat.I(12)
y <- rmvnorm(mean, V)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.