1

Suppose you have a vector p drawn from a multivariate Beta distribution (not a Dirichlet), such as the one described here ( How to construct a multivariate Beta distribution? ) with a Gaussian copula.

How would you make a draw from a multivariate Bernoulli distribution parametrised in terms of p?

fm361
  • 103

1 Answers1

0
  1. Draw from your multivariate distribution with Beta margins.

  2. Use the marginal Beta distributions as $p$ parameters for the marginal Bernoulli variables.

From this construction, you wind up with dependent Bernoulli variables.

library(copula)
set.seed(2022)

Multivariate sample size

N <- 1000

Parameter of the Gaussian copula

rho <- 0.95

Define the Gaussian copula

cop <- copula::normalCopula(rho)

Define the multivariate distribution with the

Gaussian copula "cop" and Beta(1, 1) margins

mvbeta <- copula::mvdc( cop, c("beta", "beta"), list( list(shape1 = 1, shape2 = 1), list(shape1 = 1, shape2 = 1) ) )

Draw N points from the multivariate distribution

p <- copula::rMvdc(N, mvbeta)

Extract the margins

p1 <- p[, 1] p2 <- p[, 2]

Define the two Bernoulli margins that, by this construction, are dependent

bernoulli_1 <- rbinom(N, 1, p1) bernoulli_2 <- rbinom(N, 1, p2)

Test the correlation between the Bernoulli varables.

Significant correlation is evidence of dependence derived

from the Gaussian copula of "mvbeta"

cor.test(bernoulli_1, bernoulli_2)

The Pearson correlation considered by cor.test isn't the only way to test that bernoulli_1 and bernoulli_2 are dependent, but it is a quick way.

Dave
  • 62,186
  • This is surprisingly clean, thanks! How would you supply an arbitrary covariance matrix? dispstr = "un" and the values in rho? – fm361 Aug 10 '22 at 17:51
  • You don’t supply a covariance matrix, since the margins are fixed as $U(0,1)$, but you can expand the copula to be trivariate (or higher) by passing multiple correlation values into the copula function (where I just did rho); if you have a correlation matrix of interest, you might end up writing a few lines of code to extract the correlation values from the matrix. Then you can tweak the variance as you wish by fiddling with the beta margins. The package documentation should have example in more than just two dimensions. – Dave Aug 10 '22 at 17:57