RandCovMtrx: Covariance matrix generator

View source: R/random_cov_matrix.R

RandCovMtrxR Documentation

Covariance matrix generator

Description

Generates a covariance matrix from Wishart distribution with given eigenvalues or with exponentially decreasing eigenvalues. Useful for examples and tests when an arbitrary covariance matrix is needed.

Usage

RandCovMtrx(p = 200, eigenvalues = 0.1 * exp(5 * seq_len(p)/p))

Arguments

p

dimension of the covariance matrix

eigenvalues

the vector of positive eigenvalues

Details

This function generates a symmetric positive definite covariance matrix with given eigenvalues. The eigenvalues can be specified explicitly. Or, by default, they are generated with exponential decay.

Value

covariance matrix

Examples


p<-1e1
# A non-diagonal covariance matrix
Mtrx <- RandCovMtrx(p=p)
Mtrx

HDShOP documentation built on Nov. 10, 2022, 5:12 p.m.