Simulate correlated normally distributed data

sim_cor(n, rho, means, sds, exact = FALSE)

Arguments

n

The number of values to simulate (i.e., the number of rows in the simulated data)

rho

A vector of correlations to apply to the columns of the simulated data. The number of values should be equal to one or to the number of combinations of variables to be simulated

means

A vector of means. The number of values should be equal to the number of variables to simulate

sds

A vector of standard deviations. The number of values should be equal to the number of variables to simulate

exact

A logical that indicates if the inputs should be interpreted as population of sample characteristics

Value

A data.frame with the simulated data

Examples

sim <- sim_cor(100, .74, c(0, 10), c(1, 5), exact = TRUE) cor(sim)
#> V1 V2 #> V1 1.00 0.74 #> V2 0.74 1.00
sim_summary(sim)
#> Variables: #> variable n_obs mean sd min p25 median p75 max #> V1 100 0.0000 1.0000 -3.0944 -0.7378 -0.0039 0.5965 1.9507 #> V2 100 10.0000 5.0000 -2.0493 6.2861 10.4829 13.4326 26.0857 #>