rcor: Generate Random PSD Correlation Matrices

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/rcor.R

Description

Generate random PSD correlation matrices.

Usage

1
rcor(Nvar)

Arguments

Nvar

An integer that determines the order of the random correlation matrix.

Details

rcor generates random PSD correlation matrices by (1) generating Nvar squared random normal deviates, (2) scaling the deviates to sum to Nvar, and then (3) placing the scaled values into a diagonal matrix L. Next, (4) an Nvar x Nvar orthogonal matrix, Q, is created by performing a QR decomposition of a matrix, M, that contains random normal deviates. (5) A PSD covariance matrix, C, is created from Q L Q^T and then (6) scaled to a correlation metric.

Value

A random correlation matrix.

Author(s)

Niels Waller

See Also

genCorr

Examples

1
2
R <- rcor(4)
print( R )

fungible documentation built on Sept. 29, 2021, 1:06 a.m.

Related to rcor in fungible...