MethylCapSig (version 1.0.1)

mvlognormal: Multivariate lognormal random variable generator.

Description

Given mean (Mu), variances (Sigma) and correlation structure (R) of the distribution, mvlognormal generates multivariate lognormal random variables.

Usage

mvlognormal(n, Mu, Sigma, R)

Arguments

n
Sample size (default value is 1).
Mu
Mean vector of length $k$.
Sigma
Vector of length $k$ containing the diagonal of covariances.
R
A $k \times k$ matrix comprising the correlation structure of the variables on the log-scale, i.e. $R = cor(log(X))$.

Value

Matrix of dimension $n \times k$, where $k$ is the length of the mean vector.

Details

The multivariate lognormal distribution is characterized by its associated normal distribution on the log-scale - if $X$ is lognormal, then $log(X)$ is normal. mvlognormal uses this relationship to generate lognormal random variables. Specifying the correlation structure of the actual variable does not guarantee validity of the associated normal distribution. Hence, the function takes correlation matrix of the log-transformed normal variable to ensure existence.

Examples

Run this code
## Generate 10 samples with dimension 20.
X <- mvlognormal(n = 10, Mu = runif(20, 0, 1), 
      Sigma = rep(2, 20), R = toeplitz(0.5^(0:19)));

Run the code above in your browser using DataCamp Workspace