The main function of the ellpitical slice sampler for Bayesian shrinakge regression. This function has several builtin priors and user can also provide their own prior function (written as a R function).
1 2 3 
Y 

X 

beta_hat 

penalize 
A bool 
prior 
Indicating shrinkage prior to use. 
user_prior_function 
User can provide 
sigma 
Initial value of residual standard error. The default value is half of standard error of 
s2, kap2 
Parameter of prior over sigma, an inverse gamma prior with rate s2 and shape s2. 
N 
Number of posterior samples (after burnin). 
burnin 
Number of burnin samples. 
thinning 
Number of thinnings. 
vglobal 
Initial value of global shrinkage parameter. 
verb 
Bool, if 
The Bayesian lasso model and Gibbs Sampling algorithm is described in detail in Park & Casella (2008).
loops 
A 
sigma 
A 
vglobal 
A 
beta 
A 
When using userspecified prior function, it should take a vector
coefficient and a vector
of global shrinkage parameters as arguments with same length as coefficients vector, and return the evaluation of logrithm of prior. See below for an example.
Jingyu He jingyu.he@chicagobooth.edu
Hahn, P. Richard, Jingyu He, and Hedibert Lopes. Elliptical slice sampling for Bayesian shrinkage regression with applications to causal inference. (2016).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36  ## follow the lars diabetes example
library(lars)
data(diabetes)
attach(diabetes)
## fast horseshoe
fit1 = fastHorseshoe(y, x, N = 30000, burnin = 5000, thinning = 5)
## posterior mean of beta
colMeans(fit1$beta)
## posterior mean of global shrinakge parameter
mean(fit1$v)
## posterior mean of residual variance
mean(fit1$sigma)
## average loops of ellipitical slice sampler for each sample
mean(fit1$loops)
############################################
## only penalize the first coefficient
fit2 = fastHorseshoe(y, x, penalize = c(1, rep(0, 9)))
## Not run:
############################################
## use user's own prior function
## approximate horseshoe prior, R code, which is the same as package default
log_horseshoe_approx_prior < function(beta, v){
beta = beta / v;
ll = sum(log(log(1 + 2 / beta^2)))  sum(log(v))
return(ll)
}
fit3 = fastHorseshoe(y, x, user_prior_function = log_horseshoe_approx_prior)
## End(Not run)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.