Simulate data from a multivariate normal distribution.
Arguments
- n
Number of observations (cases).
- k
Number of variables. Will be ignored if
cor
specifies a correlation matrix.- cor
A correlation value or correlation matrix of the variables. Defaults to
NULL
that generates completely random data regardless of their empirical correlations.- exact
Ensure the sample correlation matrix to be exact as specified in
cor
. This argument is passed on toempirical
inmvrnorm()
. Defaults toTRUE
.- seed
Random seed for replicable results. Defaults to
NULL
.
Examples
d1 = sim_data(n=100, k=5, seed=1)
cor_net(d1)
#> Displaying Correlation Network
d2 = sim_data(n=100, k=5, cor=0.2, seed=1)
cor_net(d2)
#> Displaying Correlation Network
cor.mat = cor_matrix(
1.0, 0.7, 0.3,
0.7, 1.0, 0.5,
0.3, 0.5, 1.0
)
d3 = sim_data(n=100, cor=cor.mat, seed=1)
cor_net(d3)
#> Displaying Correlation Network