Description Usage Arguments Value Author(s) See Also Examples
The function computes the correlation matrix of the k variables, with given marginal distributions, derived discretizing a k-variate standard normal variable with given correlation matrix
1 |
marginal |
a list of k elements, where k is the number of variables.
The i-th element of |
Sigma |
the correlation matrix of the standard multivariate normal variable |
support |
a list of k elements, where k is the number of variables. The i-th element of |
Spearman |
if |
the correlation matrix of the discretized variables
Alessandro Barbiero, Pier Alda Ferrari
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # consider 4 discrete variables
k <- 4
# with these marginal distributions
marginal <- list(0.4,c(0.3,0.6), c(0.25,0.5,0.75), c(0.1,0.2,0.8,0.9))
# generated discretizing a multivariate standard normal variable
# with correlation matrix
Sigma <- matrix(0.5,4,4)
diag(Sigma) <- 1
# the resulting correlation matrix for the discrete variables is
contord(marginal, Sigma)
# note all the correlations are smaller than the original 0.6
# change Sigma, adding a negative correlation
Sigma[1,2] <- -0.15
Sigma[2,1] <- Sigma[1,2]
Sigma
# checking whether Sigma is still positive definite
eigen(Sigma)$values # all >0, OK
contord(marginal, Sigma)
|
Loading required package: mvtnorm
Loading required package: Matrix
Loading required package: MASS
[,1] [,2] [,3] [,4]
[1,] 1.0000000 0.3638969 0.3758811 0.3569778
[2,] 0.3638969 1.0000000 0.4197643 0.4004595
[3,] 0.3758811 0.4197643 1.0000000 0.4198205
[4,] 0.3569778 0.4004595 0.4198205 1.0000000
[,1] [,2] [,3] [,4]
[1,] 1.00 -0.15 0.5 0.5
[2,] -0.15 1.00 0.5 0.5
[3,] 0.50 0.50 1.0 0.5
[4,] 0.50 0.50 0.5 1.0
[1] 2.226487 1.150000 0.500000 0.123513
[,1] [,2] [,3] [,4]
[1,] 1.0000000 -0.1046097 0.3758811 0.3569778
[2,] -0.1046097 1.0000000 0.4197643 0.4004595
[3,] 0.3758811 0.4197643 1.0000000 0.4198205
[4,] 0.3569778 0.4004595 0.4198205 1.0000000
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.