Generation of random samples from a mixture of the independent and the comonotonic copula

62 views Asked by At

Dear Stack Overflow community:

I am working in R, and I need to create random samples from a mixture of two trivariate copulas: C(u1, u2, u3) = w* C_independence (u1, u2, u3) + (1 - w) * C_comonotonic(u1, u2, u3) Let's assume that w = 0.5.

My idea was to depart from the independent copula and mix the data as follows (in this example, I generate only two observations of the three variables):

`set.seed(285)
u.ind <- matrix(runif(9), ncol = 3)
u.como <- apply(u.ind, 2, sort, decreasing = T)
w <- 0.4
mix.sam <- w * u.ind + (1 - w) * u.como`

I wonder if this is the correct way to proceed. If not, could you please help me?

Thank you in advance for your assistance!

2

There are 2 answers

1
Stéphane Laurent On BEST ANSWER

This is not correct for two reasons. Firstly, you reuse the sampled numbers from the first copula to construct the sampled numbers from the comonotonic copula. Instead, you must regenerate random numbers:

set.seed(285)
n <- 4
u.ind <- matrix(runif(n * 3), ncol = 3)
u.como <- apply(matrix(runif(n * 3), ncol = 3), 2, sort, decreasing = TRUE)

Secondly, to construct the mixture, you have to pick at random the first row of u.ind with probability w or the first row of u.como with probability 1-w. Same for the second row, the third row, etc. You can do:

w <- 0.4
mix.sam <- u.como
pick <- runif(n) < w
mix.sam[pick, ] <- u.ind[pick, ]
1
Dr. Alenezi On

Your way is incorrect. The fast and straightforward way to generate from a mixture of copula is to use the mixCopula function from the copula package.

cop <- mixCopula(list(your copula types)) ## the weight here is w = 0.5

dataCop <- rCopula(2000, cop) # generate the data form the mixture copula