Learn R Programming

GenOrd (version 2.0.0)

contord: Correlations of discretized variables

Description

The function computes the correlation matrix of the \(k\) variables, with given marginal distributions, derived discretizing a \(k\)-variate standard normal or Student's \(t\) variable with given correlation matrix

Usage

contord(marginal, Sigma,
support = list(),
Spearman = FALSE,
df=Inf,
integerdf=TRUE,
prob=FALSE)

Value

the correlation matrix of the discretized variables; if prob=TRUE, it returns a list containing the correlation along with the probability table, in case of a bivariate random variable

Arguments

marginal

a list of \(k\) elements, where \(k\) is the number of variables. The \(i\)-th element of marginal is the vector of the cumulative probabilities defining the marginal distribution of the \(i\)-th component of the multivariate variable. If the \(i\)-th component can take \(k_i\) values, the \(i\)-th element of marginal will contain \(k_i-1\) probabilities (the \(k_i\)-th is obviously 1 and shall not be included).

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 support is the vector containing the ordered values of the support of the \(i\)-th variable. By default, the support of the \(i\)-th variable is \(1,2,...,k_i\)

Spearman

if TRUE, the function finds Spearman's correlations (and it is not necessary to provide support), if FALSE (default) Pearson's correlations

df

the degrees of freedom of the multivariate Student's \(t\)

integerdf

if TRUE uses pmvt, which requires an integer value for df; otherwise, uses pmvt.alt, which integrates dmvt with possibly non-integer df

prob

if TRUE, it return also the probability table of the bivariate discrete random variable

Author

Alessandro Barbiero, Pier Alda Ferrari

See Also

ordcont, ordsample, corrcheck

Examples

Run this code
# Example 1
# consider a bivariate discrete random vector
k <- 2
# with these cumulative margins
marginal <- list(c(1/3, 2/3), c(0.1, 0.3, 0.6))
# generated discretizing a multivariate standard normal variable
# with correlation matrix
Sigma <- matrix(c(1, .75, .75, 1), 2, 2)
# the resulting joint distribution and correlation matrix
# for the bivariate discrete random vector are
res <- contord(marginal, Sigma, prob=TRUE)
res$pij
res$SigmaO
# let's check the margins are those assigned
cumsum(margin.table(res$pij,1))
cumsum(margin.table(res$pij,2))
# -> OK
# Example 2
# 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)
# Example 2
# the same margins and the same correlation matrix
# but now we consider a 4-variate Students's t with df=3
contord(marginal, Sigma, df=3)
# -> a slight reduction in magnitude for all the correlations

Run the code above in your browser using DataLab