rsmvnorm | R Documentation |
Utility function to simulate continuous random vectors from a multivariate normal distribution such that all marginal distributions are univariate standard normal.
rsmvnorm(R = R, cor.matrix = cor.matrix)
R |
integer indicating the sample size. |
cor.matrix |
matrix indicating the correlation matrix of the multivariate normal distribution. |
Checks are made to ensure that cor.matrix
is a positive definite
correlation matrix. The positive definiteness of cor.matrix
is
assessed via eigenvalues.
Returns R
random vectors of size ncol(cor.matrix)
.
Anestis Touloumis
## Simulating 10000 bivariate random vectors with correlation parameter
## equal to 0.4.
set.seed(1)
sample_size <- 10000
correlation_matrix <- toeplitz(c(1, 0.4))
simulated_normal_responses <- rsmvnorm(R = sample_size,
cor.matrix = correlation_matrix)
colMeans(simulated_normal_responses)
apply(simulated_normal_responses, 2, sd)
cor(simulated_normal_responses)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.