Learn R Programming

MultiDiscreteRNG (version 0.1.0)

discrete_cont: Compute the tetrachoric correlation matrix for a multivariate standard normal distribution

Description

This function calculates the intermediate correlation matrix of a multivariate standard normal distribution in Step 2 of the algorithm. If the resulting matrix is not positive definite, the nearest positive definite matrix is returned and a warning is issued.

Usage

discrete_cont(
  marginal,
  Sigma,
  support = list(),
  Spearman = FALSE,
  epsilon = 1e-06,
  maxit = 100
)

Value

No return values; called it to check parameter inputs

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 target correlation matrix of the discrete variables

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

A logical flag indicating whether Spearman correlation should be used

epsilon

tolerance of the algorithm convergence

maxit

maximum iterations of the algorithm to correct PD matrix

References

Ferrari and Barbiero 2012 (<https://doi.org/10.1080/00273171.2012.692630>)

Examples

Run this code
prop.vec.bin = c(0.5037236, 0.5034147)
cor.mat = matrix(c(1, 0.3, 0.3, 1), nrow = 2, byrow = TRUE)
InterMVN_Sigma = discrete_cont(marginal = prop.vec.bin, Sigma = cor.mat)$SigmaC

Run the code above in your browser using DataLab