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!
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:
Secondly, to construct the mixture, you have to pick at random the first row of
u.ind
with probabilityw
or the first row ofu.como
with probability1-w
. Same for the second row, the third row, etc. You can do: