Learn R Programming

⚠️There's a newer version (2.2-63) of this package.Take me there.

This repository contains an R package for performing "Adaptive Shrinkage."

To install the ashr package first you need to install devtools:

install.packages("devtools")
library(devtools)
install_github("stephens999/ashr")

To use the interior-point solver (optmethod = "mixIP"), you need to install MOSEK and the Rmosek package. We have provided some Mac-specific and Linux-specific instructions for installing MOSEK.

Running Adaptive Shrinkage

The main function in the ashr package is ash. To get minimal help:

library(ashr)
?ash

More background

The ashr ("Adaptive SHrinkage") package aims to provide simple, generic, and flexible methods to derive "shrinkage-based" estimates and credible intervals for unknown quantities $\beta=(\beta_1,\dots,\beta_J)$, given only estimates of those quantities ($\hat\beta=(\hat\beta_1,\dots, \hat\beta_J)$) and their corresponding estimated standard errors ($s=(s_1,\dots,s_J)$).

The "adaptive" nature of the shrinkage is two-fold. First, the appropriate amount of shrinkage is determined from the data, rather than being pre-specified. Second, the amount of shrinkage undergone by each $\hat\beta_j$ will depend on the standard error $s_j$: measurements with high standard error will undergo more shrinkage than measurements with low standard error.

Methods Outline

The methods are based on treating the vectors $\hat\beta$ and $s$ as "observed data", and then performing inference for $\beta$ from these observed data, using a standard hierarchical modelling framework to combine information across $j=1,\dots,J$.

Specifically, we assume that the true $\beta_j$ values are independent and identically distributed from some unimodal distribution $g$. By default we assume $g$ is unimodal about zero and symmetric. You can specify or estimate a different mode using the mode parameter. You can allow for asymmetric $g$ by specifying mixcompdist="halfuniform".

Then, we assume that the observations $\hat\beta_j \sim N(\beta_j,s_j)$, or alternatively the normal assumption can be replaced by a $t$ distribution by specifying df, the number of degrees of freedom used to estimate $s_j$. Actually this is important: do be sure to specify df if you can.

Copy Link

Version

Install

install.packages('ashr')

Monthly Downloads

4,465

Version

2.0.5

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Peter Carbonetto

Last Published

December 27th, 2016

Functions in ashr (2.0.5)

calc_null_vloglik

Compute vector of loglikelihood for data under null that all beta are 0
calc_loglik

Compute loglikelihood for data from ash fit
calc_logLR

Compute loglikelihood ratio for data from ash fit
calc_null_loglik

Compute loglikelihood for data under null that all beta are 0
ashci

Credible Interval Computation for the ash object
ashr

ashr
ash.workhorse

Detailed Adaptive Shrinkage function
ash

Main Adaptive Shrinkage function
calc_mixmean

Generic function of calculating the overall mean of the mixture
calc_mixsd

Generic function of calculating the overall standard deviation of the mixture
comp_dens_conv

comp_dens_conv
calc_vloglik

Compute vector of loglikelihood for data from ash fit
comp_dens_conv.normalmix

comp_dens_conv.normalmix
cdf.ash

cdf method for ash object
cdf_post

cdf_post
calc_vlogLR

Compute vector of loglikelihood ratio for data from ash fit
comp_dens

Generic function of calculating the component densities of the mixture
comp_dens_conv.unimix

density of convolution of each component of a unif mixture
comp_cdf_post

comp_cdf_post
comp_cdf

Generic function of computing the cdf for each component
comp_sd.normalmix

comp_sd.normalmix
compute_lfsr

Function to compute the local false sign rate
my_e2truncnorm

More about the truncated normal
my_e2trunct

my_e2trunct
postmean

postmean
posterior_dist

Compute Posterior
comp_mean2

Generic function of calculating the second moment of components of the mixture
comp_postmean

comp_postmean
get_density

Density method for ash object
gen_etruncFUN

gen_etruncFUN
loglik_conv.default

loglik_conv.default
loglik_conv

loglik_conv
pcdf_post

pcdf_post
comp_mean

Generic function of calculating the first moment of components of the mixture
comp_mean.normalmix

comp_mean.normalmix
igmix

Constructor for igmix class
get_lfsr

Return lfsr, lfdr, etc from ash object
my_etrunct

my_etrunct
my_vtruncnorm

This version is better than trunvnorm package
set_data

Takes raw data and sets up data object for use by ash
plogf

The log-F distribution
log_comp_dens_conv

log_comp_dens_conv
print.ash

Print method for ash object
qval.from.lfdr

Function to compute q values from local false discovery rates
log_comp_dens_conv.normalmix

log_comp_dens_conv.normalmix
logF_lik

Likelihood object for logF error distribution
log_comp_dens_conv.unimix

log density of convolution of each component of a unif mixture
my_etruncnorm

my_etruncnorm
my_etrunclogf

my_etrunclogf
plot.ash

Plot method for ash object
dens

Find density at y, a generic function
comp_postmean2

comp_postmean2
comp_postprob

comp_postprob
dens_conv

dens_conv
mixcdf.default

mixcdf.default
ncomp.default

ncomp.default
mixcdf

mixcdf
comp_postsd

comp_postsd
vcdf_post

vcdf_post
ncomp

ncomp
mixmean2

Generic function of calculating the overall second moment of the mixture
mixprop

Generic function of extracting the mixture proportions
dlogf

The log-F distribution
comp_sd

Generic function to extract the standard deviations of components of the mixture
normalmix

Constructor for normalmix class
estimate_mixprop

Estimate mixture proportions of a mixture g given noisy (error-prone) data from that mixture.
normal_lik

Likelihood object for normal error distribution
postmean2

postmean2
pm_on_zero

Generic function to extract which components of mixture are point mass on 0
postsd

postsd
unimix

Constructor for unimix class
t_lik

Likelihood object for t error distribution
summary.ash

Summary method for ash object