Learn R Programming

carts (version 0.1.0)

rmvn: Multivariate normal distribution function

Description

Draw random samples from multivariate normal distribution with variance given by a correlation matrix.

Usage

rmvn(n, mean, cor, var = NULL)

Arguments

n

number of samples

mean

matrix with mean values (either a 1xp or nxp matrix)

cor

matrix with correlation (either a 1x((p-1)*p/2) or nx((p-1)*p/2) matrix. The correlation coefficients must be given in the order R(1,2), R(1,3), ..., R(1,p), R(2,3), ... R(2,p), ... where R(i,j) is the entry in row i and column j of the correlation matrix.

var

Optional covariance matrix (instead of 'cor' argument)

Examples

Run this code
rmvn(10, cor = rep(c(-0.999, 0.999), each = 5))

Run the code above in your browser using DataLab