Learn R Programming

LassoHiDFastGibbs (version 0.1.4)

penalized_pcg_sigma2_lambda2: Penalized PCG sampler: sigma2 collapsed over lambda2

Description

Partially-collapsed Gibbs (PCG) sampler variant that samples \(\sigma^2\) using a collapsed step over \(\lambda^2\) (see implementation). Requires initial values for local scales va_init; if omitted, it is set to a vector of ones.

Usage

penalized_pcg_sigma2_lambda2(
  vy,
  mX,
  penalty_type = c("lasso", "horseshoe"),
  a,
  b,
  u,
  v,
  nsamples,
  lambda_init = 1,
  sigma2_init = 1,
  va_init = NULL,
  verbose = max(1L, floor(as.integer(nsamples)/10)),
  lower = 1e-12,
  upper = 5000
)

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.

penalty_type

Character string: "lasso" or "horseshoe".

a, b

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

u, v

Hyperparameters for the prior on \(\lambda^2\).

nsamples

Number of MCMC iterations.

lambda_init

Initial value for \(\lambda\).

sigma2_init

Initial value for \(\sigma^2\).

va_init

Optional initial local-scale vector (length p). If NULL, defaults to rep(1, ncol(mX)).

verbose

Print progress every verbose iterations (0 = silent).

lower, upper

Bounds used by the slice sampler.

Examples

Run this code
set.seed(1)
n <- 40; p <- 6
X <- matrix(rnorm(n * p), n, p)
beta <- c(1.2, 2, -1, 0.5, 0.75, 2.5)
y <- X %*% beta + rnorm(n)

out <- penalized_pcg_sigma2_lambda2(
  vy = y, mX = X, penalty_type = "lasso",
  a = 1, b = 1, u = 1, v = 1,
  nsamples = 200,
  lambda_init = 1, sigma2_init = 1,
  va_init = rep(1, p),
  verbose = 0
)

str(out)

Run the code above in your browser using DataLab