CovEst.nearPD: Covariance Estimation via Nearest Positive-Definite Matrix...

Description Usage Arguments Value References Examples

View source: R/CovEst.nearPD.R

Description

Qi and Sun (2006) proposed an algorithm for computing the positive correlation matrix with Positive Definiteness and transforming it back in order to estimate covariance matrix. This algorithm does not depend on any parameters.

Usage

1

Arguments

X

an (n\times p) matrix where each row is an observation.

Value

a named list containing:

S

a (p\times p) covariance matrix estimate.

References

\insertRef

qi_quadratically_2006CovTools

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## generate data from multivariate normal with Identity covariance.
pdim <- 5
data <- matrix(rnorm(10*pdim), ncol=pdim)

## compare against sample covariance
out1 <- cov(data)
out2 <- CovEst.nearPD(data) # apply nearPD

## visualize 2 estimated matrices
gcol <- gray((0:100)/100)
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,2), pty="s")
image(out1[,pdim:1],   col=gcol, main="sample covariance")
image(out2$S[,pdim:1], col=gcol, main="SPD Projection")
par(opar)

CovTools documentation built on Aug. 14, 2021, 1:08 a.m.