rcorrmatrix: GENERATE A RANDOM CORRELATION MATRIX BASED ON RANDOM PARTIAL...

Description Usage Arguments Value Author(s) References Examples

View source: R/hjrancor.R

Description

Generate a random correlation matrix based on random partial correlations.

Usage

1
  rcorrmatrix(d, alphad = 1)

Arguments

d

Dimension of the matrix. d should be a non-negative integer.

alphad

α parameter for partial of 1,d given 2,…,d-1, for generating random correlation matrix based on the method proposed by Joe (2006), where d is the dimension of the correlation matrix. The default value alphad=1 leads to a random matrix which is uniform over space of positive definite correlation matrices. Each correlation has a Beta(a,a) distribution on (-1,1) where a=alphad+(d-2)/2. alphad should be a positive number.

Value

A correlation matrix.

Author(s)

Weiliang Qiu weiliang.qiu@gmail.com
Harry Joe harry@stat.ubc.ca

References

Joe, H. (2006) Generating Random Correlation Matrices Based on Partial Correlations. Journal of Multivariate Analysis, 97, 2177–2189.

Examples

1
2
3
rcorrmatrix(3)
rcorrmatrix(5)
rcorrmatrix(5, alphad = 2.5)

Example output

Loading required package: MASS
           [,1]       [,2]       [,3]
[1,]  1.0000000  0.5711815 -0.3692510
[2,]  0.5711815  1.0000000 -0.7002529
[3,] -0.3692510 -0.7002529  1.0000000
           [,1]       [,2]         [,3]         [,4]       [,5]
[1,]  1.0000000 -0.5928222  0.523480744 -0.183527159  0.6645571
[2,] -0.5928222  1.0000000  0.108855102  0.608353481 -0.4118965
[3,]  0.5234807  0.1088551  1.000000000 -0.005384531 -0.1576855
[4,] -0.1835272  0.6083535 -0.005384531  1.000000000  0.2162224
[5,]  0.6645571 -0.4118965 -0.157685548  0.216222365  1.0000000
           [,1]        [,2]        [,3]        [,4]       [,5]
[1,]  1.0000000 -0.30620906 -0.17443481 -0.25114364  0.5736854
[2,] -0.3062091  1.00000000  0.01607454  0.02311423  0.2588852
[3,] -0.1744348  0.01607454  1.00000000 -0.33697323 -0.2623731
[4,] -0.2511436  0.02311423 -0.33697323  1.00000000  0.2001922
[5,]  0.5736854  0.25888520 -0.26237309  0.20019218  1.0000000

clusterGeneration documentation built on Dec. 15, 2020, 5:23 p.m.