shrinkTEGS: Default shrinkage estimation of covariance matrices

Description Usage Arguments Details Note References See Also Examples

View source: R/mainFunctions.R

Description

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

Usage

1
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:

  • lamda: a vector of lambdas (to be supplied only if some custom lambdas are to be used)

  • 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:

Note

It should be stressed that the default parameters for TEGS shrink estimator allow to compare the log likelihood criterion among distributions if the testMeanVariance is performed.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
}

SourceSet documentation built on Oct. 30, 2019, 9:38 a.m.