Learn R Programming

ashr (version 2.0.5)

ash: Main Adaptive Shrinkage function

Description

Takes vectors of estimates (betahat) and their standard errors (sebetahat), together with degrees of freedom (df) and applies shrinkage to them, using Empirical Bayes methods, to compute shrunk estimates for beta.

Usage

ash(betahat, sebetahat, mixcompdist = c("uniform", "halfuniform", "normal", "+uniform", "-uniform"), df = NULL, ...)

Arguments

betahat
a p vector of estimates
sebetahat
a p vector of corresponding standard errors
mixcompdist
distribution of components in mixture ("uniform","halfuniform" or "normal"; "+uniform" or "-uniform"), the default is "uniform". If you believe your effects may be asymmetric, use "halfuniform". If you want to allow only positive/negative effects use "+uniform"/"-uniform". The use of "normal" is permitted only if df=NULL.
df
appropriate degrees of freedom for (t) distribution of betahat/sebetahat, default is NULL which is actually treated as infinity (Gaussian)
...
Further arguments to be passed to ash.workhorse.

Value

ash returns an object of class "ash", a list with some or all of the following elements (determined by outputlevel)

Details

This function is actually just a simple wrapper that passes its parameters to ash.workhorse which provides more documented options for advanced use. See readme for more details.

See Also

ash.workhorse for complete specification of ash function

ashci for computation of credible intervals after getting the ash object return by ash()

Examples

Run this code
beta = c(rep(0,100),rnorm(100))
sebetahat = abs(rnorm(200,0,1))
betahat = rnorm(200,beta,sebetahat)
beta.ash = ash(betahat, sebetahat)
names(beta.ash)
head(beta.ash$result) # the main dataframe of results
graphics::plot(betahat,beta.ash$result$PosteriorMean,xlim=c(-4,4),ylim=c(-4,4))

CIMatrix=ashci(beta.ash,level=0.95)
print(CIMatrix)

#Illustrating the non-zero mode feature
betahat=betahat+5
beta.ash = ash(betahat, sebetahat)
graphics::plot(betahat,beta.ash$result$PosteriorMean)
betan.ash=ash(betahat, sebetahat,mode=5)
graphics::plot(betahat, betan.ash$result$PosteriorMean)
summary(betan.ash)

Run the code above in your browser using DataLab