Description Usage Arguments Value Author(s) See Also Examples
The function returns the lower and upper bounds of the correlation coefficients of each pair of discrete variables given their marginal distributions, i.e., returns the range of feasible bivariate correlations.
1 |
marginal |
a list of k elements, where k is the number of variables.
The i-th element of |
support |
a list of k elements, where k is the number of variables. The i-th element of |
Spearman |
|
The functions returns a list of two matrices: the former contains the lower bounds, the latter the upper bounds of the feasible pairwise correlations (on the extra-diagonal elements)
Alessandro Barbiero, Pier Alda Ferrari
1 2 3 4 5 6 7 8 9 10 11 | # four variables
k <- 4
# with 2, 3, 4, and 5 categories (Likert scales, by default)
kj <- c(2,3,4,5)
# and these marginal distributions (set of cumulative probabilities)
marginal <- list(0.4, c(0.6,0.9), c(0.1,0.2,0.4), c(0.6,0.7,0.8,0.9))
corrcheck(marginal) # lower and upper bounds for Pearson's rho
corrcheck(marginal, Spearman=TRUE) # lower and upper bounds for Spearman's rho
# change the supports
support <- list(c(0,1), c(1,2,4), c(1,2,3,4), c(0,1,2,5,10))
corrcheck(marginal, support=support) # updated bounds
|
Loading required package: mvtnorm
Loading required package: Matrix
Loading required package: MASS
[[1]]
4 x 4 Matrix of class "dsyMatrix"
[,1] [,2] [,3] [,4]
[1,] 1.0000000 -0.9128709 -0.5687111 -0.8660254
[2,] -0.9128709 1.0000000 -0.9641540 -0.5270463
[3,] -0.5687111 -0.9641540 1.0000000 -0.9850366
[4,] -0.8660254 -0.5270463 -0.9850366 1.0000000
[[2]]
4 x 4 Matrix of class "dsyMatrix"
[,1] [,2] [,3] [,4]
[1,] 1.0000000 0.6085806 0.8530667 0.5773503
[2,] 0.6085806 1.0000000 0.5191599 0.9486833
[3,] 0.8530667 0.5191599 1.0000000 0.4925183
[4,] 0.5773503 0.9486833 0.4925183 1.0000000
[[1]]
4 x 4 Matrix of class "dsyMatrix"
[,1] [,2] [,3] [,4]
[1,] 1.0000000 -0.9759001 -0.6429904 -0.9607689
[2,] -0.9759001 1.0000000 -0.9883037 -0.6250763
[3,] -0.6429904 -0.9883037 1.0000000 -0.9961464
[4,] -0.9607689 -0.6250763 -0.9961464 1.0000000
[[2]]
4 x 4 Matrix of class "dsyMatrix"
[,1] [,2] [,3] [,4]
[1,] 1.0000000 0.6506000 0.9644856 0.6405126
[2,] 0.6506000 1.0000000 0.6274944 0.9844952
[3,] 0.9644856 0.6274944 1.0000000 0.6177652
[4,] 0.6405126 0.9844952 0.6177652 1.0000000
[[1]]
4 x 4 Matrix of class "dsyMatrix"
[,1] [,2] [,3] [,4]
[1,] 1.0000000 -0.8017837 -0.5687111 -0.7056563
[2,] -0.8017837 1.0000000 -0.9553936 -0.3771892
[3,] -0.5687111 -0.9553936 1.0000000 -0.9682511
[4,] -0.7056563 -0.3771892 -0.9682511 1.0000000
[[2]]
4 x 4 Matrix of class "dsyMatrix"
[,1] [,2] [,3] [,4]
[1,] 1.0000000 0.5345225 0.8530667 0.4704375
[2,] 0.5345225 1.0000000 0.4559833 0.9499579
[3,] 0.8530667 0.4559833 1.0000000 0.4013146
[4,] 0.4704375 0.9499579 0.4013146 1.0000000
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.