cma_combination.Rd
Second CMA step: "glue" copulas and marginals into the same data structure.
cma_combination(x, cdf, copula)
x | A rectangular (non-tidy) data structure with the sorted marginals (ascending order). |
---|---|
cdf | A rectangular (non-tidy) data structure with the CDF's. |
copula | A rectangular (non-tidy) data structure with the copulas. |
A tabular (non-tidy) tibble
with the joint scenarios.
set.seed(123) margins <- matrix(stats::rnorm(20), ncol = 2) colnames(margins) <- c("a", "b") probs <- rep(1 / 10, 10) # separate sep <- cma_separation(x = margins, p = probs) # combinate comb <- cma_combination(margins, sep$cdf, sep$copula) # The result is identical margins # matrix #> a b #> [1,] -0.56047565 1.2240818 #> [2,] -0.23017749 0.3598138 #> [3,] 1.55870831 0.4007715 #> [4,] 0.07050839 0.1106827 #> [5,] 0.12928774 -0.5558411 #> [6,] 1.71506499 1.7869131 #> [7,] 0.46091621 0.4978505 #> [8,] -1.26506123 -1.9666172 #> [9,] -0.68685285 0.7013559 #> [10,] -0.44566197 -0.4727914 comb # tibble #> # A tibble: 10 × 2 #> a b #> <dbl> <dbl> #> 1 -0.560 1.22 #> 2 -0.230 0.360 #> 3 1.56 0.401 #> 4 0.0705 0.111 #> 5 0.129 -0.556 #> 6 1.72 1.79 #> 7 0.461 0.498 #> 8 -1.27 -1.97 #> 9 -0.687 0.701 #> 10 -0.446 -0.473 all.equal(margins[ , "a"], comb$a) #> [1] TRUE all.equal(margins[ , "b"], comb$b) #> [1] TRUE