Description Usage Arguments Value Author(s) References See Also Examples
For K binary (Bernoulli) random variables X_1, ..., X_K, this function transforms the odds ratios measure of association O_ij between every pair (X_i, X_j) to the correlation C_ij where
C_ij = cov(X_i, X_j) / sqrt(var(X_i) * var(X_j))
and
O_ij = P(X_i = 1, X_j = 1) * P(X_i = 0, X_j = 0) / P(X_i = 1, X_j = 0) * P(X_i = 0, X_j = 1).
1 | Odds2Corr(odds, marg.probs)
|
odds |
A K x K matrix where the i-th row and the j-th column represents the odds ratio O_ij between variables i and j. |
marg.probs |
A vector with K elements of marginal probabilities where the i-th entry refers to P(X_i = 1). |
The function return a list with the correlations and the pairwise probabilities.
corr |
A matrix of the same dimension as |
pair.proba |
A matrix of the same dimension as |
Thomas Suesse.
Maintainer: Johan Barthelemy johan@uow.edu.au.
Lee, A.J. (1993). Generating Random Binary Deviates Having Fixed Marginal Distributions and Specified Degrees of Association The American Statistician 47 (3): 209-215.
Qaqish, B. F., Zink, R. C., and Preisser, J. S. (2012). Orthogonalized residuals for estimation of marginally specified association parameters in multivariate binary data. Scandinavian Journal of Statistics 39, 515-527.
Corr2Odds
for converting correlation to odds ratio.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # from Qaqish et al. (2012)
or <- matrix(c(Inf, 0.281, 2.214, 2.214,
0.281, Inf, 2.214, 2.214,
2.214, 2.214, Inf, 2.185,
2.214, 2.214, 2.185, Inf), nrow = 4, ncol = 4, byrow = TRUE)
rownames(or) <- colnames(or) <- c("Parent1", "Parent2", "Sibling1", "Sibling2")
# hypothetical marginal probabilities
p <- c(0.2, 0.4, 0.6, 0.8)
# converting odds ratio to correlation
corr <- Odds2Corr(odds = or, marg.probs = p)
print(corr)
|
Loading required package: cmm
Loading required package: Rsolnp
Loading required package: numDeriv
$corr
Parent1 Parent2 Sibling1 Sibling2
Parent1 1.0000000 -0.2156821 0.1445775 0.1076353
Parent2 -0.2156821 1.0000000 0.1847014 0.1445775
Sibling1 0.1445775 0.1847014 1.0000000 0.1563619
Sibling2 0.1076353 0.1445775 0.1563619 1.0000000
$pair.proba
Parent1 Parent2 Sibling1 Sibling2
Parent1 0.20000000 0.03773512 0.1483313 0.1772216
Parent2 0.03773512 0.40000000 0.2843283 0.3483313
Sibling1 0.14833129 0.28432833 0.6000000 0.5106405
Sibling2 0.17722164 0.34833129 0.5106405 0.8000000
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.