Learn R Programming

LassoHiDFastGibbs (version 0.1.5)

blasso_gibbs_2block_bs: Bayesian lasso Gibbs sampler: 2-block (beta–sigma2) variant

Description

Implements a two-block Gibbs sampler for the Bayesian lasso regression model in which the regression coefficients are updated jointly with the noise variance \(\sigma^2\) in one block, while the global shrinkage parameter and local shrinkage parameters are updated conditionally in separate steps.

Usage

blasso_gibbs_2block_bs(
  vy,
  mX,
  a,
  b,
  u,
  v,
  nsamples,
  lambda_init = 1,
  sigma2_init = 1,
  verbose = max(1L, floor(nsamples/5))
)

Value

A list with components:

mBeta

Matrix of beta draws (nsamples x p).

vsigma2

Vector of sigma^2 draws (length nsamples).

vlambda2

Vector of lambda^2 draws (length nsamples).

Arguments

vy

Numeric response vector of length n.

mX

Numeric design matrix of dimension n x p.

a, b

Hyperparameters for the inverse-gamma prior on sigma^2.

u, v

Hyperparameters for the prior on lambda^2.

nsamples

Integer number of MCMC iterations.

lambda_init

Initial value for lambda.

sigma2_init

Initial value for sigma^2.

verbose

Print progress every verbose iterations (0 = silent).

Examples

Run this code
set.seed(1)
n <- 30; p <- 6
X <- matrix(rnorm(n * p), n, p)
y <- rnorm(n)
out <- blasso_gibbs_2block_bs(
  vy = y, mX = X,
  a = 1, b = 1, u = 1, v = 1,
  nsamples = 200,
  lambda_init = 1, sigma2_init = 1,
  verbose = 0
)
str(out)

Run the code above in your browser using DataLab