cor.mat.Rd
Generate two type of correlation matrix
cor.mat(p, rho, type='toeplitz')
p | a positive integer, the dimension of correlation matrix. |
---|---|
rho | a value between 0 and 1, a baseline vlaue of correlation coefficient. |
type | a character, specify the type of correlation matrix and only include 'toeplitz' and 'identity' in current version. |
The argument rho specify the size of correlation coeffient. As for argument type, if type='toeplitz', sigma_ij=rho^|i-j|; if type ='identity', sigma_ij=rho when i!=j and sigma_ij=1 when i=j.
return a correlation matrix with a type of specified structure.
nothing.
Liu Wei
nothing
cov2cor
cor.mat(5, 0.5)#> [,1] [,2] [,3] [,4] [,5] #> [1,] 1.0000 0.500 0.25 0.125 0.0625 #> [2,] 0.5000 1.000 0.50 0.250 0.1250 #> [3,] 0.2500 0.500 1.00 0.500 0.2500 #> [4,] 0.1250 0.250 0.50 1.000 0.5000 #> [5,] 0.0625 0.125 0.25 0.500 1.0000cor.mat(5, 0.5, type='identity')#> [,1] [,2] [,3] [,4] [,5] #> [1,] 1.0 0.5 0.5 0.5 0.5 #> [2,] 0.5 1.0 0.5 0.5 0.5 #> [3,] 0.5 0.5 1.0 0.5 0.5 #> [4,] 0.5 0.5 0.5 1.0 0.5 #> [5,] 0.5 0.5 0.5 0.5 1.0