Skip to contents

Creates a random correlation matrix.

Usage

cor_gen(n_var, cov_bounds = c(-1, 1))

Arguments

n_var

integer number of variables.

cov_bounds

a vector containing the bounds of the covariance matrix.

Details

The result from cor_gen can be used directly with the cor_matrix argument of questionnaire_gen.

Examples

cor_gen(n_var = 10)
#>              [,1]        [,2]        [,3]        [,4]        [,5]        [,6]
#>  [1,]  1.00000000  0.06870909  0.09310086  0.40473923  0.17954089 -0.19370616
#>  [2,]  0.06870909  1.00000000 -0.09084016  0.53053783  0.12019166 -0.32317147
#>  [3,]  0.09310086 -0.09084016  1.00000000  0.24638230 -0.11923876  0.07066641
#>  [4,]  0.40473923  0.53053783  0.24638230  1.00000000 -0.01795640 -0.04471689
#>  [5,]  0.17954089  0.12019166 -0.11923876 -0.01795640  1.00000000 -0.09713209
#>  [6,] -0.19370616 -0.32317147  0.07066641 -0.04471689 -0.09713209  1.00000000
#>  [7,] -0.31353985  0.61873620  0.07342955  0.06313287  0.32972749 -0.34900811
#>  [8,]  0.32968783  0.15345944  0.32936529  0.38727273 -0.56903485  0.25726106
#>  [9,]  0.18503091 -0.27727230 -0.06030438 -0.50586051  0.13998835 -0.25395525
#> [10,] -0.02104111 -0.08986347 -0.10048205  0.23910356  0.40334189  0.44717664
#>              [,7]        [,8]        [,9]       [,10]
#>  [1,] -0.31353985  0.32968783  0.18503091 -0.02104111
#>  [2,]  0.61873620  0.15345944 -0.27727230 -0.08986347
#>  [3,]  0.07342955  0.32936529 -0.06030438 -0.10048205
#>  [4,]  0.06313287  0.38727273 -0.50586051  0.23910356
#>  [5,]  0.32972749 -0.56903485  0.13998835  0.40334189
#>  [6,] -0.34900811  0.25726106 -0.25395525  0.44717664
#>  [7,]  1.00000000 -0.27692166 -0.19505726 -0.22827095
#>  [8,] -0.27692166  1.00000000 -0.39606239  0.01167408
#>  [9,] -0.19505726 -0.39606239  1.00000000 -0.13955743
#> [10,] -0.22827095  0.01167408 -0.13955743  1.00000000