Postinference.MHLS: Post-inference for lasso estimator

Description Usage Arguments Details Value Examples

View source: R/MHInference.R

Description

Provides confidence intervals for the set of active coefficients from lasso estimator using Metropolis-Hastings sampler.

Usage

1
2
3
Postinference.MHLS(X, Y, lbd, weights = rep(1, ncol(X)), tau = rep(1,
  ncol(X)), sig2.hat, alpha = 0.05, nChain = 10, niterPerChain = 500,
  parallel = FALSE, ncores = 2L, returnSamples = FALSE, ...)

Arguments

X

predictor matrix.

Y

response vector.

lbd

penalty term of lasso. By letting this argument be "cv.1se" or "cv.min", users can have the cross-validated lambda that gives either minimum squared error or that is within 1 std error bound.

weights

weight vector with length equal to the number of coefficients. Default is rep(1, ncol(X)).

tau

numeric vector. Standard deviaion of proposal distribution for each beta. Adjust the value to get relevant level of acceptance rate. Default is rep(1, ncol(X)).

sig2.hat

variance of error term.

alpha

confidence level for confidence interval.

nChain

the number of chains. For each chain, different plug-in beta will be generated from its confidence region.

niterPerChain

the number of iterations per chain.

parallel

logical. If parallel = TRUE, uses parallelization. Default is parallel = FALSE.

ncores

integer. The number of cores to use for parallelization.

returnSamples

logical. If returnSamples = TRUE, print Metropolis-Hastings samples.

...

auxiliary MHLS arguments.

Details

This function provides post-selection inference for lasso estimator. Using Metropolis-Hastings sampler with multiple chains, generates (1-alpha) confidence interval for each active coefficients. Set returnSamples = TRUE to check the samples. Check the acceptance rate and adjust tau accordingly. We recommend to set nChain >= 10 and niterPerChain >= 500.

Value

MHsamples

a list of class MHLS.

confidenceInterval

(1-alpha) confidence interval for each active coefficient.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
set.seed(123)
n <- 5
p <- 10
X <- matrix(rnorm(n*p),n)
Y <- X %*% rep(1,p) + rnorm(n)
sig2 <- 1
lbd <- .37
weights <- rep(1,p)
Postinference.MHLS(X = X, Y = Y, lbd = lbd, sig2.hat = 1, alpha = .05,
nChain = 3, niterPerChain = 20, parallel = TRUE)
Postinference.MHLS(X = X, Y = Y, lbd = lbd, sig2.hat = 1, alpha = .05,
nChain = 3, niterPerChain = 20, parallel = TRUE, returnSamples = TRUE)

EAlasso documentation built on Sept. 1, 2017, 9:03 a.m.