GitHub - stephens999/ashr: An R package for adaptive shrinkage (original) (raw)
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")
Running Adaptive Shrinkage
The main function in the ashr package is ash
. To get minimal help:
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 hatbetaj\hat\beta_jhatbetaj will depend on the standard error sjs_jsj: 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 hatbeta\hat\betahatbeta and sss as "observed data", and then performing inference for beta\betabeta from these observed data, using a standard hierarchical modelling framework to combine information across j=1,dots,Jj=1,\dots,Jj=1,dots,J.
Specifically, we assume that the true betaj\beta_jbetaj values are independent and identically distributed from some unimodal distribution ggg. By default we assume ggg is unimodal about zero and symmetric. You can specify or estimate a different mode using the mode
parameter. You can allow for asymmetric ggg by specifyingmixcompdist="halfuniform"
.
Then, we assume that the observations hatbetajsimN(betaj,sj)\hat\beta_j \sim N(\beta_j,s_j)hatbetajsimN(betaj,sj), or alternatively the normal assumption can be replaced by a ttt distribution by specifying df
, the number of degrees of freedom used to estimate sjs_jsj. Actually this is important: do be sure to specify df
if you can.