| simulate_correlated | R Documentation |
Simulate correlated Gaussian variables
simulate_correlated(
n,
means,
sds = 1,
rho = 0,
structure = c("independent", "exchangeable", "ar1", "custom"),
correlation = NULL,
variable_names = NULL,
seed = NULL,
batch = NULL
)
n |
Number of observations. |
means |
Variable means. |
sds |
Variable standard deviations. |
rho |
Correlation used when |
structure |
Correlation structure: one of |
correlation |
A custom correlation matrix or tidy table returned by
|
variable_names |
Optional variable names. |
seed |
Optional random seed. |
batch |
Optional single positive whole number. When given, the
simulator runs |
A simulab_sim base data.frame with one row per observation and
columns id and one column per variable. Three tidy tables come from
as.data.frame(): what = "parameters" has one row per variable with
columns variable, mean and sd; what = "correlation" and
what = "covariance" each have one row per matrix cell with columns
row, column and correlation or covariance. The covariance is the
correlation matrix scaled by sds on both sides, so sds are standard
deviations rather than variances.
simulate_correlated(
n = 100,
means = c(0, 1, 2),
sds = c(1, 2, 1),
rho = 0.4,
structure = "exchangeable",
seed = 1
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.