| augment_correlated | R Documentation |
Add correlated variables to existing data
augment_correlated(
data,
specification,
rho = 0,
tau = NULL,
structure = c("independent", "exchangeable", "ar1", "custom"),
correlation = NULL,
group = NULL,
seed = NULL,
envir = parent.frame()
)
data |
Base |
specification |
New variable definitions, in the |
rho, tau, structure, correlation |
Copula correlation arguments.
|
group |
Optional grouping variable. With grouping, one definition is generated as correlated observations within each group. |
seed |
Optional random seed. |
envir |
Formula evaluation environment. |
A simulab_sim base data.frame holding every column of data
plus one column per new variable. Two tidy tables come from
as.data.frame(): what = "definitions" restates the specification, and
what = "latent_correlation" describes the latent Gaussian correlation.
Without group that table has one row per correlation-matrix cell, with
columns row, column and correlation; with group the correlation is
across the observations inside each group, so the table instead has one
row per group with columns group, observations, rho and structure.
data <- data.frame(id = 1:100)
specification <- define_variables(
define_variable("a", formula = "0", variance = "1", distribution = "normal"),
define_variable("b", formula = "0", variance = "1", distribution = "normal")
)
result <- augment_correlated(data, specification = specification, rho = 0.5, seed = 1)
head(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.