Learn R Programming

HDShOP (version 0.1.5)

RandCovMtrx: 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))

Value

covariance matrix

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.

Examples

Run this code

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

Run the code above in your browser using DataLab