View source: R/random_correlation_matrix.R
rand_cor_mat | R Documentation |
Creates a symmetric n x n
correlation matrix with user-defined minimum and maximum
correlations based on a continuous uniform distribution.
rand_cor_mat(
n = 5,
min.cor = -1,
max.cor = 1,
pos.def = FALSE,
small.positive = NULL
)
n |
A scalar defining the dimensions of the correlation matrix. |
min.cor |
A scalar defining the minimum correlation. |
max.cor |
A scalar defining the maximum correlation. |
pos.def |
When |
small.positive |
Argument passed to |
A symmetric n x n
correlation matrix. When pos.def = TRUE
,
the correlation matrix is guaranteed to be positive (semi)-definite.
# Simulate and visualise a random correlation matrix with 10 columns and rows.
cor_mat <- rand_cor_mat(
n = 10,
min.cor = -0.2,
max.cor = 0.8,
pos.def = TRUE
)
plot_matrix(
mat = cor_mat,
order = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.