| r_mvdist | R Documentation |
r_mvdist() combines a copula (see r_copula()) with user-specified
marginal distributions, returning a data frame. This is a flexible way to
simulate mixed-type data sets with known dependence, e.g. for simulation
studies or to benchmark synthesizers.
Each element of margins is either
a quantile function function(p) (e.g. from margin_categorical() or
margin_empirical()),
a character string naming a distribution with a q* function, e.g.
"norm", "gamma", "pois", or
a list with element dist and further parameters, e.g.
list(dist = "gamma", shape = 2, rate = 1).
r_mvdist(n, margins, copula = "gaussian", ..., seed = NULL)
n |
Number of rows. |
margins |
A (named) list of marginal specifications. |
copula |
Copula family, see |
... |
Further arguments passed to |
seed |
Optional random seed. |
A data frame with one column per margin.
df <- r_mvdist(
500,
margins = list(
income = list(dist = "lnorm", meanlog = 10, sdlog = 0.5),
age = list(dist = "unif", min = 18, max = 80),
sector = margin_categorical(c("agri", "industry", "services"),
c(0.1, 0.3, 0.6))
),
copula = "gaussian", corr = make_corr(3, "exchangeable", 0.4), seed = 1
)
str(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.