Description Usage Arguments Details Value Examples
View source: R/create_covcor.R
Simulate a correlation matrix from a given nb of variables.
1 | sim_cor_mat(nvars = 2, is_cor = TRUE)
|
nvars |
Positive number of variables, must be >= 2. |
is_cor |
TRUE (default): Return the correlation matrix. FALSE: return the covariance matrix. |
Simulate a correlation matrix from a given nb of variables by creating
a covariance matrix and transforming it to a correlation matrix with
stats::cov2cor
. The method was copied from simstudy::genCorMat()
to whom I express my gratitude.
Correlation matrix nvars x nvars
1 2 | mat <- sim_cor_mat(4)
stopifnot(identical(dim(mat), c(4L, 4L)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.