exact_horseshoe {Mhorseshoe}R Documentation

Run exact MCMC algorithm for horseshoe prior

Description

The exact MCMC algorithm introduced in Section 2.1 of Johndrow et al. (2020) was implemented in this function. This algorithm is the horseshoe estimator that updates the global shrinkage parameter \tau using Metropolis-Hastings algorithm, and uses blocked-Gibbs sampling for (\tau, \beta, \sigma). The local shrinkage parameter \lambda_{j},\ j = 1,2,...,p is updated by the rejection sampler.

Usage

exact_horseshoe(
  X,
  y,
  burn = 1000,
  iter = 5000,
  a = 1/5,
  b = 10,
  s = 0.8,
  tau = 1,
  sigma2 = 1,
  w = 1,
  alpha = 0.05
)

Arguments

X

Design matrix, X \in \mathbb{R}^{N \times p}.

y

Response vector, y \in \mathbb{R}^{N}.

burn

Number of burn-in samples. Default is 1000.

iter

Number of samples to be drawn from the posterior. Default is 5000.

a

Parameter of the rejection sampler, and it is recommended to leave it at the default value, a = 1/5.

b

Parameter of the rejection sampler, and it is recommended to leave it at the default value, b = 10.

s

s^{2} is the variance of tau's MH proposal distribution. 0.8 is a good default. If set to 0, the algorithm proceeds by fixing the global shrinkage parameter \tau to the initial setting value.

tau

Initial value of the global shrinkage parameter \tau when starting the algorithm. Default is 1.

sigma2

error variance \sigma^{2}. Default is 1.

w

Parameter of gamma prior for \sigma^{2}. Default is 1.

alpha

100(1-\alpha)\% credible interval setting argument.

Details

See Mhorseshoe or browseVignettes("Mhorseshoe").

Value

BetaHat

Posterior mean of \beta.

LeftCI

Lower bound of 100(1-\alpha)\% credible interval for \beta.

RightCI

Upper bound of 100(1-\alpha)\% credible interval for \beta.

Sigma2Hat

Posterior mean of \sigma^{2}.

TauHat

Posterior mean of \tau.

LambdaHat

Posterior mean of \lambda_{j},\ j=1,2,...p..

BetaSamples

Samples from the posterior of \beta.

LambdaSamples

Lambda samples through rejection sampling.

TauSamples

Tau samples through MH algorithm.

Sigma2Samples

Samples from the posterior of the parameter sigma^{2}.

References

Johndrow, J., Orenstein, P., & Bhattacharya, A. (2020). Scalable Approximate MCMC Algorithms for the Horseshoe Prior. In Journal of Machine Learning Research (Vol. 21).

Examples

# Making simulation data.
set.seed(123)
N <- 50
p <- 100
true_beta <- c(rep(1, 10), rep(0, 90))

X <- matrix(1, nrow = N, ncol = p) # Design matrix X.
for (i in 1:p) {
  X[, i] <- stats::rnorm(N, mean = 0, sd = 1)
}

y <- vector(mode = "numeric", length = N) # Response variable y.
e <- rnorm(N, mean = 0, sd = 2) # error term e.
for (i in 1:10) {
  y <- y + true_beta[i] * X[, i]
}
y <- y + e

# Run
result <- exact_horseshoe(X, y, burn = 0, iter = 100)

# posterior mean
betahat <- result$BetaHat

# Lower bound of the 95% credible interval
leftCI <- result$LeftCI

# Upper bound of the 95% credible interval
RightCI <- result$RightCI


[Package Mhorseshoe version 0.1.2 Index]