labels <- c("P", "C", "N1", "N2", "U")
n <- 100
marginals <- list(
"P" = list(type = "poisson", lambda = 2),
"C" = list(type = "categorical", p = c(0.3, 0.2, 0.5)),
"N1" = list(type = "normal", mean = -1, sd = 2),
"U" = list(type = "uniform", min = -2, max = -1)
)
correlation <- matrix(
c(1, -0.3, -0.1, 0, 0.5,
-0.3, 1, 0.3, -0.5, -0.7,
-0.1, 0.3, 1, -0.3, -0.3,
0, -0.5, -0.3, 1, 0.1,
0.5, -0.7, -0.3, 0.1, 1),
nrow = 5, ncol = 5
)
data <- correlated_regressors(
labels = labels, n = n, marginals = marginals, correlation = correlation
)
head(data)
#> P C N1 N2 U
#> 1 1 3 -0.08888801 -0.1189768 -1.926488
#> 2 2 3 -2.31672614 -0.9196652 -1.345979
#> 3 2 3 0.14146463 0.4040866 -1.947112
#> 4 2 2 -2.86028032 -1.0175959 -1.195731
#> 5 0 3 -1.32352049 -0.6800921 -1.761985
#> 6 0 3 -4.03115485 -0.2170961 -1.695337