Generate Correlation Matrix.
Examples
# List of probability distributions
dists <- list(
normal = function(n) rnorm(n, mean = 0, sd = 1),
uniform = function(n) runif(n, min = 0, max = 1),
exponential = function(n) rexp(n, rate = 1),
poisson = function(n) rpois(n, lambda = 1),
binomial = function(n) rbinom(n, size = 10, prob = 0.5)
)
# Generate correlation matrix
cor_matrix <- cor_matrix(num_samples = 100, num_vars = 5, dists = dists)
# Print correlation matrix
print(cor_matrix)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1.000000e+00 0.16574655 0.07203118 -0.006606531 7.107618e-05
#> [2,] 1.657465e-01 1.00000000 0.12033562 -0.027319417 1.756293e-02
#> [3,] 7.203118e-02 0.12033562 1.00000000 -0.162796530 -1.028019e-02
#> [4,] -6.606531e-03 -0.02731942 -0.16279653 1.000000000 -1.483971e-01
#> [5,] 7.107618e-05 0.01756293 -0.01028019 -0.148397087 1.000000e+00