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.
createSigma(nVar, meanR = 0.3, sdR = 0, diagonal = 1)
| nVar | The number of variables in the correlation matrix. |
|---|---|
| meanR | The average correlation, provided to |
| sdR | The variation in the correlations, provided to |
| diagonal | The value on the diagonal of the returned matrix: will normally be 1. |
A matrix of nVar x nVar.
mvrnorm, rnorm, matrix
createSigma(3, .5, .1);#> [,1] [,2] [,3] #> [1,] 1.0000000 0.6045641 0.4005455 #> [2,] 0.6045641 1.0000000 0.3973101 #> [3,] 0.4005455 0.3973101 1.0000000