genCorMat: Create a correlation matrix

Description Usage Arguments Details Value Examples

View source: R/genCorMat.R

Description

Create a correlation matrix

Usage

1
genCorMat(nvars, cors = NULL)

Arguments

nvars

number of rows and columns (i.e. number of variables) for correlation matrix

cors

vector of correlations.

Details

If the vector cors is not specified, a random correlation matrix is generated with no assumptions. If the vector is provided, it should be interpreted as the lower triangle of the correlation matrix, and is specified by reading down the columns. For example, if CM is the correlation matrix and nvars = 3, then CM[2,1] = cors[1], CM[3,1] = cors[2], and CM[3,2] = cors[3].

Value

correlation matrix of size nvars x nvars

Examples

1
2
3
4
5
genCorMat(3, c(.3, -.2, .1))
genCorMat(3)

genCorMat(5, c(.3, -.2, .1, .2, .5, .2, -.1, .3, .1, .2))
genCorMat(5)

kgoldfeld/simstudy documentation built on Nov. 8, 2018, 7:41 p.m.