Package 'gigg'

Title: Group Inverse-Gamma Gamma Shrinkage for Sparse Regression with Grouping Structure
Description: A Gibbs sampler corresponding to a Group Inverse-Gamma Gamma (GIGG) regression model with adjustment covariates. Hyperparameters in the GIGG prior specification can either be fixed by the user or can be estimated via Marginal Maximum Likelihood Estimation. Jonathan Boss, Jyotishka Datta, Xin Wang, Sung Kyun Park, Jian Kang, Bhramar Mukherjee (2021) <arXiv:2102.10670>.
Authors: Jon Boss [aut], Bhramar Mukherjee [aut], Michael Kleinsasser [cre]
Maintainer: Michael Kleinsasser <[email protected]>
License: GPL-2
Version: 0.2.1
Built: 2024-11-09 06:25:48 UTC
Source: CRAN

Help Index


Solve function with Cholesky decomposition.

Description

An Rcpp function that solves M*U = V.

Usage

chol_solve(M, V)

Arguments

M

A (M x M) symmetric positive definite matrix.

V

A (M x 1) vector.

Value

The solution to M*U = V.


Example data set

Description

Contains a list with data and parameters to run the package examples. Please see ?gigg_fixed and ?grouped_igg_mmle pages for use.

Usage

concentrated

Format

An object of class list of length 15.

Examples

concentrated
names(concentrated)

Inverse digamma function.

Description

Evaluate the inverse digamma function.

Usage

digamma_inv(y, precision = 1e-08)

Arguments

y

value to evaluate the inverse digamma function at.

precision

default = 1e-08.

Value

Numeric inverse digamma value.


Example data set

Description

Contains a list with data and parameters to run the package examples. Please see ?gigg_fixed and ?grouped_igg_mmle pages for use.

Usage

distributed

Format

An object of class list of length 15.

Examples

distributed
names(distributed)

GIGG regression

Description

Perform GIGG (Group Inverse-Gamma Gamma) regression. This package implements a Gibbs sampler corresponding to a Group Inverse-Gamma Gamma (GIGG) regression model with adjustment covariates. Hyperparameters in the GIGG prior specification can either be fixed by the user or can be estimated via Marginal Maximum Likelihood Estimation.

Usage

gigg(
  X,
  C,
  Y,
  method = "mmle",
  grp_idx,
  alpha_inits = rep(0, ncol(C)),
  beta_inits = rep(0, ncol(X)),
  a = rep(0.5, length(unique(grp_idx))),
  b = rep(0.5, length(unique(grp_idx))),
  sigma_sq_init = 1,
  tau_sq_init = 1,
  n_burn_in = 500,
  n_samples = 1000,
  n_thin = 1,
  verbose = TRUE,
  btrick = FALSE,
  stable_solve = TRUE
)

Arguments

X

A (n x p) matrix of covariates that to apply GIGG shrinkage on.

C

A (n x k) matrix of covariates that to apply no shrinkage on (typically intercept + adjustment covariates).

Y

A length n vector of responses.

method

Either fixed for GIGG regression with fixed hyperparameters or mmle for GIGG regression with MMLE. Defaults to method = "mmle".

grp_idx

A length p integer vector indicating which group of the G groups the p covariates in X belong to. The grp_idx vector must be a sequence from 1 to G with no skips. A valid example is 1,1,1,2,2,3,3,3,4,5,5.

alpha_inits

A length k vector containing initial values for the regression coefficients corresponding to C.

beta_inits

A length p vector containing initial values for the regression coefficients corresponding to X.

a

A length G vector of shape parameters for the prior on the group shrinkage parameters. The a parameter is only used if the user selects method = 'fixed'. If method = 'mmle', then a = rep(1/n, length(unique(grp_idx))).

b

A length G vector of shape parameters for the prior on the individual shrinkage parameters. If method = 'mmle', then the b is used as an inital value for the MMLE procedure.

sigma_sq_init

Initial value for the residual error variance (double).

tau_sq_init

Initial value for the global shrinkage parameter (double).

n_burn_in

The number of burn-in samples (integer).

n_samples

The number of posterior draws (integer).

n_thin

The thinning interval (integer).

verbose

Boolean value which indicates whether or not to print the progress of the Gibbs sampler.

btrick

Boolean value which indicates whether or not to use the computational trick in Bhattacharya et al. (2016). Only recommended if number of covariates is much larger than the number of observations.

stable_solve

Boolean value which indicates whether or not to use Cholesky decomposition during the update of the regression coefficients corresponding to X. In our experience, stable_solve = TRUE is slightly slower, but more stable.

Value

A list containing

  • "draws" - A list containing the posterior draws of
    (1) the regression coefficients (alphas and betas)
    (2) the individual shrinkage parameters (lambda_sqs)
    (3) the group shrinkage parameters (gamma_sqs)
    (4) the global shrinkage parameter (tau_sqs) and
    (5) the residual error variance (sigma_sqs).
    The list also contains details regarding the dataset (X, C, Y, grp_idx) and Gibbs sampler details (n_burn_in, n_samples, and n_thin).

  • "beta.hat" - Posterior mean of betas

  • "beta.lcl.95" - 95% credible interval lower bound of betas

  • "beta.ucl.95" - 95% credible interval upper bound of betas

  • "alpha.hat" - Posterior mean of alpha

  • "alpha.lcl.95" - 95% credible interval lower bound of alphas

  • "alpha.ucl.95" - 95% credible interval upper bound of alphas

  • "sigma_sq.hat" - Posterior mean of sigma squared

  • "sigma_sq.lcl.95" - 95% credible interval lower bound of sigma sq.

  • "sigma_sq.ucl.95" - 95% credible interval upper bound of sigma sq.

References

Boss, J., Datta, J., Wang, X., Park, S.K., Kang, J., & Mukherjee, B. (2021). Group Inverse-Gamma Gamma Shrinkage for Sparse Regression with Block-Correlated Predictors. arXiv

Examples

X = concentrated$X
C = concentrated$C
Y = as.vector(concentrated$Y)
grp_idx = concentrated$grps
alpha_inits = concentrated$alpha
beta_inits = concentrated$beta

gf = gigg(X, C, Y, method = "fixed", grp_idx, alpha_inits, beta_inits,
          n_burn_in = 200, n_samples = 500, n_thin = 1,  
          verbose = TRUE, btrick = FALSE, stable_solve = FALSE)

gf_mmle = gigg(X, C, Y, method = "mmle", grp_idx, alpha_inits, beta_inits,
                n_burn_in = 200, n_samples = 500, n_thin = 1, 
                verbose = TRUE, btrick = FALSE, 
                stable_solve = FALSE)

Gibbs sampler for GIGG regression with fixed hyperparameters.

Description

An Rcpp function that implements a Gibbs sampler for GIGG regression with fixed hyperparameters.

Usage

gigg_fixed_gibbs_sampler(
  X,
  C,
  Y,
  grp_idx,
  grp_size,
  grp_size_cs,
  alpha_inits,
  beta_inits,
  lambda_sq_inits,
  gamma_sq_inits,
  eta_inits,
  p,
  q,
  tau_sq_init = 1,
  sigma_sq_init = 1,
  nu_init = 1,
  n_burn_in = 500L,
  n_samples = 1000L,
  n_thin = 1L,
  stable_const = 1e-07,
  verbose = TRUE,
  btrick = FALSE,
  stable_solve = FALSE
)

Arguments

X

A (n x M) matrix of covariates that we want to apply GIGG shrinkage on.

C

A (n x K) matrix of covariates that we want to apply no shrinkage on (typically intercept + adjustment covariates).

Y

A (n x 1) column vector of responses.

grp_idx

A (1 x M) row vector indicating which group of the J groups the M covariates in X belong to.

grp_size

A (1 x J) row vector indicating the number of covariates in each group.

grp_size_cs

A (1 x J) row vector that is the cumulative sum of grp_size (indicating the indicies where each group ends).

alpha_inits

A (K x 1) column vector containing initial values for the regression coefficients corresponding to C.

beta_inits

A (M x 1) column vector containing initial values for the regression coefficients corresponding to X.

lambda_sq_inits

A (M x 1) column vector containing initial values for the local shrinkage parameters.

gamma_sq_inits

A (J x 1) column vector containing initial values for the group shrinkage parameters.

eta_inits

A (J x 1) column vector containing initial values for the mixing parameters.

p

A (J x 1) column vector of shape parameter for the prior on the group shrinkage parameters.

q

A (J x 1) column vector of shape parameter for the prior on the individual shrinkage parameters.

tau_sq_init

Initial value for the global shrinkage parameter (double).

sigma_sq_init

Initial value for the residual variance (double).

nu_init

Initial value for the augmentation variable (double).

n_burn_in

The number of burn-in samples (integer).

n_samples

The number of posterior draws (integer).

n_thin

The thinning interval (integer).

stable_const

Parameter that controls numerical stability of the algorithm (double).

verbose

Boolean value which indicates whether or not to print the progress of the Gibbs sampler.

btrick

Boolean value which indicates whether or not to use the computational trick in Bhattacharya et al. (2016). Only recommended if number of covariates is much larger than the number of observations.

stable_solve

default to FALSE

Value

A list containing the posterior draws of (1) the regression coefficients (alphas and betas) (2) the individual shrinkage parameters (lambda_sqs) (3) the group shrinkage parameters (gamma_sqs) (4) the global shrinkage parameter (tau_sqs) and (5) the residual error variance (sigma_sqs). The list also contains details regarding the dataset (X, C, Y, grp_idx) and Gibbs sampler details (n_burn_in, n_samples, and n_thin).


Gibbs sampler for GIGG regression with hyperparameters estimated via MMLE.

Description

An Rcpp function that implements a Gibbs sampler for GIGG regression with hyperparameters estimated via MMLE.

Usage

gigg_mmle_gibbs_sampler(
  X,
  C,
  Y,
  grp_idx,
  grp_size,
  grp_size_cs,
  alpha_inits,
  beta_inits,
  lambda_sq_inits,
  gamma_sq_inits,
  eta_inits,
  p_inits,
  q_inits,
  tau_sq_init = 1,
  sigma_sq_init = 1,
  nu_init = 1,
  n_burn_in = 500L,
  n_samples = 1000L,
  n_thin = 1L,
  stable_const = 1e-07,
  verbose = TRUE,
  btrick = FALSE,
  stable_solve = FALSE
)

Arguments

X

A (n x M) matrix of covariates that we want to apply GIGG shrinkage on.

C

A (n x K) matrix of covariates that we want to apply no shrinkage on (typically intercept + adjustment covariates).

Y

A (n x 1) column vector of responses.

grp_idx

A (1 x M) row vector indicating which group of the J groups the M covariates in X belong to.

grp_size

A (1 x J) row vector indicating the number of covariates in each group.

grp_size_cs

A (1 x J) row vector that is the cumulative sum of grp_size (indicating the indicies where each group ends).

alpha_inits

A (K x 1) column vector containing initial values for the regression coefficients corresponding to C.

beta_inits

A (M x 1) column vector containing initial values for the regression coefficients corresponding to X.

lambda_sq_inits

A (M x 1) column vector containing initial values for the local shrinkage parameters.

gamma_sq_inits

A (J x 1) column vector containing initial values for the group shrinkage parameters.

eta_inits

A (J x 1) column vector containing initial values for the mixing parameters.

p_inits

A (J x 1) column vector of initial shape parameter for the prior on the group shrinkage parameters.

q_inits

A (J x 1) column vector of inital shape parameter for the prior on the individual shrinkage parameters.

tau_sq_init

Initial value for the global shrinkage parameter (double).

sigma_sq_init

Initial value for the residual variance (double).

nu_init

Initial value for the augmentation variable (double).

n_burn_in

The number of burn-in samples (integer).

n_samples

The number of posterior draws (integer).

n_thin

The thinning interval (integer).

stable_const

Parameter that controls numerical stability of the algorithm (double).

verbose

Boolean value which indicates whether or not to print the progress of the Gibbs sampler.

btrick

Boolean value which indicates whether or not to use the computational trick in Bhattacharya et al. (2016). Only recommended if number of covariates is much larger than the number of observations.

stable_solve

default to FALSE

Value

A list containing the posterior draws of (1) the regression coefficients (alphas and betas) (2) the individual shrinkage parameters (lambda_sqs) (3) the group shrinkage parameters (gamma_sqs) (4) the global shrinkage parameter (tau_sqs) and (5) the residual error variance (sigma_sqs). The list also contains details regarding the dataset (X, C, Y, grp_idx) and Gibbs sampler details (n_burn_in, n_samples, and n_thin).


Iterative one rank update for matrix inverse.

Description

An Rcpp function that computes the matrix inverse of XtX + D_pos.

Usage

quick_solve(XtX_inv, D_pos, vec_draw)

Arguments

XtX_inv

A precomputed (M x M) matrix inverse.

D_pos

A (M x 1) vector of the square root of the diagonal entries in the D matrix.

vec_draw

A (M x 1) vector drawn from a multivariate normal distribution.

Value

The solution to (XtX + D)*U = vec_draw.


Randomly generate a generalized inverse gaussian random variable.

Description

Randomly generates one draw from a generalized inverse gaussian distribution.

Usage

rgig_cpp(chi, psi, lambda)

Arguments

chi

A positive double.

psi

A positive double.

lambda

A non-negative double.

Value

A random draw from the generalized inverse gaussian distribution with parameters chi, psi, and lambda (double).