Learn R Programming

groupedHyperframe.random (version 0.2.2)

mvrnorm2: Expand Types of Sigma in mvrnorm

Description

To accommodate more types of Sigma in function mvrnorm.

Usage

mvrnorm2(
  n,
  mu,
  sd,
  Sigma = diag(x = sd^2, nrow = d, ncol = d),
  row.prefix,
  col.prefix,
  ...
)

Value

Function mvrnorm2() returns a double

matrix.

Arguments

n

integer scalar, sample size

mu

numeric scalar or vector, multivariate means \(\mathbf{\mu}\)'s

sd

numeric scalar or a vector, standard deviation(s)

Sigma

numeric variance-covariance matrix, see function mvrnorm

row.prefix, col.prefix

(optional) character scalars

...

additional parameter of function mvrnorm

Details

Argument of parameter sd could be

scalar

sd is recycled to the length of mu

vector

check that length of sd and mu must be the same

Then a diagonal matrix with vector sd^2 on the diagonal elements is used as the variance-covariance matrix \(\Sigma\)