ObtainMultBinaryDist {mipfp} | R Documentation |
Generating a multivariate Bernoulli joint-distribution
Description
This function applies the IPFP procedure to obtain a joint distribution of
K
multivariate binary (Bernoulli) variables X_1
, ..., X_K
.
It requires as input the odds ratio or alternatively the correlation as a measure of association between all the binary variables and a vector of marginal probabilities.
This function is useful when one wants to simulate and draw from a multivariate binary distribution when only first order (marginal probabilities) and second order moments (correlation or odds ratio) are available.
Usage
ObtainMultBinaryDist(odds = NULL, corr = NULL, marg.probs, ...)
Arguments
odds |
A |
corr |
A |
marg.probs |
A vector with |
... |
Additional arguments that can be passed to the |
Value
A list whose elements are mainly determined by the Ipfp
function.
joint.proba |
The resulting multivariate joint-probabilities (from |
stp.crit |
The final value of the |
conv |
Boolean indicating whether the |
check.margins |
A list returning, for each margin, the absolute maximum deviation between
the desired and generated margin. Ideally the elements should approximate
0 (from |
label |
The names of the variables. |
Note
It is important to note that either the odds ratio defined in odds
or
the correlations described in corr
must be provided.
Author(s)
Thomas Suesse
Maintainer: Johan Barthelemy <johan@uow.edu.au>.
References
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.
See Also
Ipfp
for the function used to estimate the
distribution; RMultBinary
to simulate the
estimated joint-distribution; Corr2Odds
and
Odds2Corr
to convert odds ratio to correlation
and conversely.
Examples
# initial odds ratios 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)
# estimating the joint-distribution
p.joint <- ObtainMultBinaryDist(odds = or, corr = NULL, marg.probs = p)
print(p.joint$joint.proba)
# obtain identical solution when providing correlation
corr <- Odds2Corr(odds = or, marg.probs = p)$corr
p.joint.alt <- ObtainMultBinaryDist(corr = corr, marg.probs = p)
# checking if the results are truly identicals
diff <- sum(abs(p.joint.alt$joint.proba - p.joint$joint.proba))
cat('Sum of the absolute deviations: ', diff, '\n')