varcov {corpcor}R Documentation

Variance of the Entries of the Covariance Matrix

Description

varcov computes both the standard empirical covariance matrix (S) and a matrix containing the estimated variances var(s_{ij}) of the individual components of (S).

Usage

varcov(x, type=c("unbiased", "ML"), verbose=TRUE)

Arguments

x a data matrix
type estimate unbiased or ML variant of empirical covariance matrix (default: "unbiased", as in cov)
verbose report progress while computing (default: TRUE)

Details

The variances of the empirical covariance matrix are needed to compute shrinkage estimates - see Schaefer and Strimmer (2005).

Value

varcov returns a list with the following two components:

S the empirical covariance matrix.
var.S a matrix containing the variances of each element in S.

Author(s)

Korbinian Strimmer (http://www.statistik.lmu.de/~strimmer/).

References

Schaefer, J., and Strimmer, K. (2005). A shrinkage approach to large-scale covariance estimation and implications for functional genomics. Submitted to SAGMB.

See Also

cov.shrink.

Examples

# load corpcor library
library("corpcor")

# small n, large p
p <- 100
n <- 20

# generate random pxp covariance matrix
sigma <- matrix(rnorm(p*p),ncol=p)
sigma <- crossprod(sigma)+ diag(rep(0.1, p))

# simulate multinormal data of sample size n  
sigsvd <- svd(sigma)
Y <- t(sigsvd$v %*% (t(sigsvd$u) * sqrt(sigsvd$d)))
X <- matrix(rnorm(n * ncol(sigma)), nrow = n) %*% Y

# estimate covariance matrix
S <- cov(X)

# varcov produces the same results as cov
vc <- varcov(X)
sum(abs(vc$S-S))

[Package corpcor version 1.1 Index]