rcormat: Randomly Generate Low-Rank Correlation Matrix

View source: R/rcormat.R

rcormatR Documentation

Randomly Generate Low-Rank Correlation Matrix

Description

Generate a correlation matrix as R = LL' where the rows of L are of length 1, L is of rank r and the matrix L is sparse (depending on sparse.prop. The loadings in L are sampled from a standard normal distribution, after which sparse.prop is used to set a randomly chosen number of loadings in each row equal to zero. To ensure that a correlation matrix results, the rows are normalized.

Usage

rcormat(m, r = 3L, sparse.prop = 0.5)

Arguments

m

integer; the number of variables.

r

integer; the required rank.

sparse.prop

the proportion of zeros in the rows of the matrix.

Value

A list with the following components:

R

The sampled correlation matrix

L

The loading matrix

Examples

R <- rcormat(m = 10)$R
eigen(R)

cds documentation built on April 16, 2025, 1:10 a.m.