SourceSet (version 0.1.0)

shrinkTEGS: Default shrinkage estimation of covariance matrices

Description

The function adds a small quantity to the diagonals of covariance matrix estimates to regularize them.

Usage

shrinkTEGS(s, s1, s2, param = list(probs = 0.05, type = "min"))

Arguments

s

covariance matrix estimte in the pooled sample

s1

sample covariance matrix estimate in class 1

s2

sample covariance matrix estimate in class 2

param

list of parameters:

  • type: minimum (min), maximum (max) or optimal (opt)

  • probs: the numeric value of probability with value in [0,1]

Details

To determine the quantity to add to the diagonals of covariance matrices, the function:

  • finds the distributions of the sample variances of the p variables in the two classes and in the pooled sample

  • computes the probs percentile of each of these distributions

  • use the minimum, maximum or optimal (one for each matrix) (type)

References

Huang, Y.-T. and Lin, X. (2013). Gene set analysis using variance component tests. BMC Bioinformatics, 14(1), 210.

See Also

testMeanVariance, parameters

Examples

Run this code
# NOT RUN {
if(require(mvtnorm)){

  ## Generate two random samples of size 50 from two multivariate normal distributions
  # sample size
  n<-50
  # true parameters of class 1 and class 2
  param.class1<-simulation$condition1
  param.class2<-simulation$condition2$`5`$`2`
  # simulated dataset
  data.class1<-rmvnorm(n = n,mean =param.class1$mu ,sigma =param.class1$S)
  data.class2<-rmvnorm(n = n,mean =param.class2$mu ,sigma=param.class2$S)
  data<-rbind(data.class1,data.class2)
  classes<-c(rep(1,nrow(data.class1)),rep(2,nrow(data.class2)))

  ## estimated parameters: maximum likelihood estimate
  s<-cov(data)
  s1<-cov(data.class1)
  s2<-cov(data.class2)

  ## default parameters:
  # use the minimum of median variances distributions of the three supplied covariance matrices
  def.shrink<-shrinkTEGS(s,s1,s2)
  def.shrink$lambda

  ## use customize lamdas
  def.shrink<-shrinkTEGS(s,s1,s2,param = list(lambda=c(0.1,0.2,0.3)))
  def.shrink$lambda

  # use for each covariance matrix the 0.4 percentile of its variances distributions
  def.shrink<-shrinkTEGS(s,s1,s2,param = list(type="opt",probs=0.4))
  def.shrink$lambda
}
# }

Run the code above in your browser using DataCamp Workspace