vash: Main Variance Adaptive SHrinkage function

Description Usage Arguments Details Value References Examples

Description

Takes vectors of standard errors (sehat), and applies shrinkage to them, using Empirical Bayes methods, to compute shrunk estimates for variances.

Usage

1
2
3
vash(sehat, df, betahat = NULL, randomstart = FALSE, singlecomp = FALSE,
  unimodal = c("auto", "variance", "precision"), prior = NULL, g = NULL,
  estpriormode = TRUE, priormode = NULL, scale = 1, maxiter = 5000)

Arguments

sehat

a p vector of observed standard errors

df

scalar, appropriate degree of freedom for (chi-square) distribution of sehat

betahat

a p vector of estimates (optional)

randomstart

logical, indicating whether to initialize EM randomly. If FALSE, then initializes to prior mean (for EM algorithm) or prior (for VBEM)

singlecomp

logical, indicating whether to use a single inverse-gamma distribution as the prior distribution for the variances

unimodal

put unimodal constraint on the prior distribution of variances ("variance") or precisions ("precision"). This also can be automatically chosen ("auto") by comparing the likelihoods.

prior

string, or numeric vector indicating Dirichlet prior on mixture proportions (defaults to "uniform", or 1,1...,1; also can be "nullbiased" 1,1/k-1,...,1/k-1 to put more weight on first component)

g

the prior distribution for variances (usually estimated from the data; this is used primarily in simulated data to do computations with the "true" g)

estpriormode

logical, indicating whether to estimate the mode of the unimodal prior

priormode

specified prior mode (only works when estpriormode=FALSE).

scale

a scalar or a p vector, such that sehat/scale are exchangeable, i.e, can be modeled by a common unimodal prior.

maxiter

maximum number of iterations of the EM algorithm

Details

See vignette for more details.

Value

vash returns an object of class "vash", a list with the following elements

fitted.g

Fitted mixture prior

sd.post

A vector consisting the posterior estimate of standard deviations (square root of variances) from the mixture

PosteriorPi

A p*k matrix consisting the mixture proportions of the posterior distribution of variance (k is number of mixture components)

PosteriorShape

A p*k matrix consisting the shape parameters of the inverse-gamma posterior distribution of variance (k is number of mixture components)

PosteriorRate

A p*k matrix consisting the rate parameters of the inverse-gamma posterior distribution of variance (k is number of mixture components)

pvalue

A vector of p-values

qvalue

A vector of q-values

fit

The fitted mixture object

unimodal

Denoting whether unimodal variance prior or unimodal precision prior has been used

opt.unimodal

Denoting whether unimodal variance prior or unimodal precision prior model gets higher likelihood

call

A call in which all of the specified arguments are specified by their full names

data

A list consisting the input sehat, df and betahat

References

Lu, M., & Stephens, M. (2016). Variance Adaptive Shrinkage (vash): Flexible Empirical Bayes estimation of variances. bioRxiv, 048660.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
##An simple example
#generate true variances (sd^2) from an inverse-gamma prior
sd = sqrt(1/rgamma(100,5,5)) 
#observed standard errors are estimates of true sd's
sehat = sqrt(sd^2*rchisq(100,7)/7) 
#run the vash function
fit = vash(sehat,df=7) 
#plot the shrunk sd estimates against the observed standard errors
plot(sehat, fit$sd.post, xlim=c(0,10), ylim=c(0,10)) 

##Running vash with a pre-specified g, rather than estimating it
sd = sqrt(c(1/rgamma(100,5,4),1/rgamma(100,10,9)))
sehat = sqrt(sd^2*rchisq(100,7)/7)
true_g = igmix(c(0.5,0.5),c(5,10),c(4,9)) # define true g 
#Passing this g into vash causes it to i) take the shape and the rate for each component from this g, 
#and ii) initialize pi to the value from this g.
se.vash = vash(sehat, df=7, g=true_g)

mengyin/vashr documentation built on May 22, 2019, 6:51 p.m.