Description Usage Arguments Value References Examples
View source: R/CovEst.nearPD.R
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.
1 |
X |
an (n\times p) matrix where each row is an observation. |
a named list containing:
a (p\times p) covariance matrix estimate.
qi_quadratically_2006CovTools
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.