Learn R Programming

ashr (version 1.0.12)

ashn: Multi-Mode Adaptive Shrinkage function

Description

This is a wrapper function that takes a grid value of $mu$ and then consider the model $betahat_j - mu ~ g()$,and eqnbeta_j ~ N(0,sebetahat^2) or student t distribution. $mu$ should be a grid of mu,this wrapper function would select the best $mu$ and reports the ash item based on that $mu$.

Usage

ashn(betahat, sebetahat, mixcompdist = c("uniform", "halfuniform", "normal", "+uniform", "-uniform"), df = NULL, mu = 20, ncores = FALSE, ...)

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"), the default value would be "uniform"
df
appropriate degrees of freedom for (t) distribution of betahat/sebetahat, default is NULL(Gaussian)
mu
Could be a vector of grid values for mu. that this wrapper would select based on likelihood principle. Could also be a positive integer greater or equal to 4, then mu number of grid values would be generated from [-abs(mean(betahat)),2*abs(mean(betahat)], equally spaced.
ncores
Whether to use parallel computing, defaults to FALSE, user could specify number of cores they would like to use. Further, if user does not specify and length(betahat)>50000, then the function would perform parallel computation using number of CPU cores on the current host.

Value

ashm returns a list of objects ashm returns a list of objects

Details

All other inputs are exactly the same as the main function ash, and would pass to the main function to evaluate the likelihood.

See Also

ash the main function that this wrapper function is calling

Examples

Run this code
beta = c(rep(0,100),rnorm(100))+0.2
sebetahat = abs(rnorm(200,0,1))
betahat = rnorm(200,beta,sebetahat)
beta.ashn = ashn(betahat, sebetahat,mu=20)
#beta.ashn4 = ashn(betahat, sebetahat,mu=20,ncores=4)
print(beta.ashn[[1]])  #best ash object
print(beta.ashn[[2]])  #corresponding mode (0 or some other values)
print(beta.ashn[[3]])  #log-likelihood for all models


Run the code above in your browser using DataLab