## uncorrelated columns:
rmvbin(10, margprob=c(0.3,0.9))
## correlated columns
m <- cbind(c(1/2,1/5,1/6),c(1/5,1/2,1/6),c(1/6,1/6,1/2))
rmvbin(10, commonprob=m)
## same as the second example, but faster if the same probabilities are
## used repeatedly (commonprob2sigma rather slow)
sigma <- commonprob2sigma(m)
rmvbin(10, margprob = diag(m), sigma = sigma)
## The default 'simulvals' may not work for very small marginal
## probabilities. E.g., for
p1 <- 0.0206
p2 <- 0.0318
m <- matrix(c(1, 0.5, 0.5, 1), ncol = 2)
## rmvbin(1, margprob = c(p1,p2), bincorr = m) fails with 'Extrapolation
## occurred ... margprob and commonprob not compatible?'
## (reported by in 2025-12).
## Using e.g.
s <- simul.commonprob(margprob = c(p1, p2), corr = seq(-1, 1, by = 0.05))
## makes things work:
rmvbin(10, margprob = c(p1,p2), bincorr = m, simulvals = s)
Run the code above in your browser using DataLab