View source: R/random_correlation_matrix.R
struc_cor_mat | R Documentation |
Creates a symmetric n x n
correlation matrix with user-defined structure and rank.
struc_cor_mat(
n = 5,
base.cor = 0.5,
range = NULL,
rank = 3,
skew = 0,
base.mat = NULL,
pos.def = FALSE,
small.positive = NULL
)
n |
A scalar defining the dimensions of the correlation matrix. |
base.cor |
A scalar defining the baseline correlation. |
range |
A scalar defining the range of correlations around the baseline. By default,
|
rank |
A scalar defining the rank of the correlation matrix. |
skew |
A scalar defining the skewness imposed on the correlations.
Note: |
base.mat |
An optional |
pos.def |
When |
small.positive |
Argument passed to |
A symmetric n x n
correlation matrix with defined rank.
When pos.def = TRUE
, the correlation matrix is guaranteed to be positive (semi)-definite.
# Simulate and visualise a correlation matrix with 10 columns and rows, rank equal to 4 and
# negatively skewed correlations.
cor_mat <- struc_cor_mat(
n = 10,
base.cor = 0.3,
range = 0.7,
rank = 4,
skew = -0.5
)
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.