userfriendlyscience (version 0.7.0)

createSigma: createSigma: convenience function for mvrnorm

Description

This function is made to quickly generate a Sigma matrix of the type required by mvrnorm. By specifying the number of variables, the mean correlation, and how much variation there should be in the correlations, it's easy to quickly generate a correlation matrix.

Usage

createSigma(nVar, meanR = 0.3, sdR = 0, diagonal = 1)

Arguments

nVar

The number of variables in the correlation matrix.

meanR

The average correlation, provided to rnorm together with sdR to generate the correlations.

sdR

The variation in the correlations, provided to rnorm together with meanR to generate the correlations.

diagonal

The value on the diagonal of the returned matrix: will normally be 1.

Value

A matrix of nVar x nVar.

See Also

mvrnorm, rnorm, matrix

Examples

Run this code
# NOT RUN {
createSigma(3, .5, .1);
# }

Run the code above in your browser using DataCamp Workspace